I am trying to use the following in the TESTS tab: pm.environment.set(“creatClockingReq”, pm.request)
Then in the GET request, I want to run this POST request inside the Pre-request script to add some logic…
I am trying the following: pm.sendRequest(pm.environment.get(“creatClockingReq”))
But I am getting a 500 error on the POST request when calling it from the pre-request, but once running it alone it works just fine Oo,
Would you know how to solve this issue or a better idea to achieve what I am trying to do?
I am also trying the following, but does not work, I do not get it.
It is the same code I am using in the POST request, the only difference is that I am trying to send it using the pm.sendRequest…
Do you get an error if you send those id values in the body, as hardcoded strings? As in, "1234".
I’m just thinking of things that are different here and it looks like those values are number but those would be stored as strings in an environment file. Does wrapping them in in parseInt(pm.environment.get('deviceId')) have an impact?
Can you compare this to the working request that you send in the GUI?
Check both in the Console Logs.
Is anything missing.
I don’t think there is anything wrong with your code, but the response is not returning the body, which is causing the latest error as it can’t parse an empty body.
The following is an similar request to Postman Echo for comparison.
I checked and the code matches each other, it is the same code.
The values in the body do not matter I can send it as a string or integer the backend will convert it anyway (as long as it is a number), it works either way in the original POST collection.
This one does not make any sense to me, to be honest…
Could it be related to the header values? For every single request to this API I need to pass the same 2 headers: