Forum Discussion
I think this has more to do with how and when postman executes the pre-request script. The pre-request script calculates the signature, which has to contain the payload in the case of POST/PUT/PATCH requests. If the pre-request script runs before the resource path or body variable substitutions are done, then the signature generated by the pre-request script won't contain the final value, it'll contain the tokenized value.
For example, when the pre-request script performs this line:
var resource_path = request.url.replace(/(^{{url}})([^\?]+)(\?.*)?/, '$2');
the value of request.url is still
{{url}}/device/devices/{{id}}
There's a little regex to ignore the {{url}} piece, but the id variable still hasn't been substituted in. So the signature is getting calculated using the wrong resource path. I would have suggested what you tried for the ID to fix it, but maybe there's a missing "/" between the resource_path and the id? Also, this change invalidates the pre-request script so that it only works with this call and not others.
I imagine something similar is happening with the payload. Since your payload is equal to this:
{ "name": "{{groupName}}" }
At the time the pre-request script runs, the signature is getting calculated incorrectly, based on the pre-variable insertion string, rather than the post-variable insertion string. When the pre-request script runs this line:
var request_vars = (http_verb == 'GET'||http_verb == 'DELETE') ? http_verb + epoch + resource_path : http_verb + epoch + request.data + resource_path;
I'm not sure how to fix it, but I imagine it would be something deep in Postman.
Related Content
- 23 days ago