'Postman - Error 400 Bad Request

I'm trying to access an API using Postman to get a response using basic authentication, but when I submit the data, it gives me the dreaded 400 error, which apparently indicates that some headers aren't set up properly.

Here's the API info:

Request

Endpoint: {loginUrl}
Data to submit: an email and a password
POST /login HTTP/1.1
Host: {baseUrl}
Accept: application/json
Content-Type: application/json
Content-Length: 68

{
    "email": "{email}",
    "password": "{password}"
}

And in response, I should get an encrypted token in form of JSON, instead I'm getting this error.

Here are the postman screenshots:

Postman_01

Postman_02

Am I missing something?



Solution 1:[1]

I also faced the same issue and i updated my postman header with the below image. And issue solved. enter image description here

Solution 2:[2]

In case anyone finds this helpful, I ran into the same issue and the culprit turned out to be missing headers. I knew I needed the "Content-Type": "application/json" header, which I already had in place, but I didn't know that I was missing two other headers.

The solution for me was also adding the "Content-Length" and "Host" headers in Postman.

I see some others have questioned the need for the "Content-Length" header, but in my case, the minimum three needed were "Content-Type", "Content-Length", and "Host" or it would always fail.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2