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:
Am I missing something?
Best Answer
From the lack of details it's difficult to offer a specific answer but I can offer something that you can try - The
Request
data you posted in the question looks like you should be adding:In the
Body
section of the request but your images don't show that you've added that to theBody
on any request, you've added it as aAuth
header instead, so remove that before trying again. I'm not sure of the need to add theContent-Length
header as that will change for different username and password combinations in the payload or for the length of the response.