My problem is opposite of most of problems that have been posted in web like
Why is my API working with Postman but not working with Java Get request or HttpClient returning Bad Request while Postman is working fine
My rest API is working very well on my java android app but it fail to login using Thunder Client VSCode extension or desktop postman running with Xampp. All of these API tools returning Status: 400 Bad Request
and can’t verify even first field of login form while in android app it has no problem.
What has caused this problem?
I am using retrofit2 for my working java codes: (phone = 123456, password = 123456789)
@POST("http://localhost/myapp/index.php/auth/login")
ApiResponse<AuthResponse> login(@Body UserLogin userLogin);
and in VSCode
and this is the my Xampp details:
2
Answers
The problem here might be related to the headers of your request.
Make sure you are sending the same headers via Postman/VS Code as the ones used in your Android app
Your app is doing something that you are missing in the Postman call. For example:
To solve this you’ll need to see the full request that your app is making – often default logging is not enough.
There are a few ways to do this:
Fiddler
,Charles
etc.) to sniff network trafficI would go with 1) as the simplest. The likelihood is you are missing some headers or similar.