skip to Main Content

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

enter image description here

and this is the my Xampp details:

enter image description here

2

Answers


  1. 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

    Login or Signup to reply.
  2. Your app is doing something that you are missing in the Postman call. For example:

    • Missing headers
    • Fields
    • Content formatting

    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:

    1. Increase logging client-side (eg via OKHttp logging interceptor)
    2. Check on the server side.
    3. Use a proxy (Fiddler, Charles etc.) to sniff network traffic

    I would go with 1) as the simplest. The likelihood is you are missing some headers or similar.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search