0

I have a API call that takes a POST body of

raw: {"category":1, "fmipstatus":true} and it is of type JSON.

Content-Type is application/json

I use Postman to send this API call and I get a 200 response code.

I want to code this call as part of a Postman Pre-request Script

I have the following:

 method: 'POST',
  header: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'Basic NDc0OmVmMzAwZThkNGFjNTQ2ZjU3ZjhjYWQ5ZWQwMjUyNGIxYTI5NmQwM2M='
  },
  body: {
            mode: 'raw',
            raw: JSON.stringify( {category: 1, fmipstatus: false} )
    }

I always a 401. In the first API through Postman, if I put garbage in there, I also get a 401 response code.

So I am thinking somehow in my Postman script, the body is defined incorrectly.

Does anyone the error?

reza
  • 5,972
  • 15
  • 84
  • 126

1 Answers1

0

401 is an authorization error. Something is wrong with your Auth token, either its expired, incorrect, or you're passing it incorrectly.

SpecialK711
  • 48
  • 1
  • 8
  • but the same call works using Postman and direct API call with and the response code is a 200 – reza Aug 15 '22 at 15:40