Apologies in advance if this is silly but I hope to find some resolution to this issue
I am sending a POST request that uses a collection variable - I can confirm from Console that the request body is resolving the variable correctly. However, the response is still 401.
As soon as I replace the variable with the hard-coded value, seems to work fine. So… what’s up?
I appreciate any help! Please let me know if I can provide more information.
Where Org1Id is my collection variable. I have it set to persist values so I can confirm that initial and current values are set. I can also confirm that the value for variable is being resolved correctly (as seen in Console) on request:
However, on running the POST request, I see a 401.
It seems to be a simple mistake that you are making if possible connect with me on [email protected] via google chat I’m availabe online now happy to help you
Here’s my post-request script (I do not have a pre-request script). It basically saves the value from identifier of the entity to a collection variable:
pm.test("Status code is 200", () =>
{
pm.response.to.have.status(200);
});
var data = JSON.parse(responseBody);
pm.collectionVariables.set("App1Id", data.EntityId);
I will connect with you on gtalk, @jency.stella19! Thank you!
Are you perhaps testing against a mock server that you had set up against your collection? If you are, then I have a couple of ideas what the issue may be.
Unfortunately my ideas relate specifically to calls to a Postman mock server.
It’s a bit difficult to explain and most probably quite confusing.
I’ve run into issues before where it seemed that the variable was not populated but it was simply because the mock example body contained the same variable as the request body. The problem was that the variable was defined in a specific environment (Env-A). The collection was set to use Env-A but the mock server was set to use Env-B. Unfortunately the variable was in Env-B too but with a different value. Therefor the mock server could not find the appropriate response when comparing the request body values since the values differed when calling from the collection vs on the mock server side.
Unfortunately I don’t think this applies to your situation though.
Because you are getting a 401 Unauthorized response, can I assume that the OrganisationId is used in your authentication process? In other words, authentication fails when you send in {{Org1Id}} but succeeds when sending in the actual “hardcoded” value?
I suggest you make use of the Postman Echo API ( Echo API | Postman Learning Center) It will allow you to see exactly what you are sending in with your request and what the value is that your request body contains. While I cannot explain your result it is clear to me that what you think your variable is sending in and what is actually sent, is most probably not that same.