Unable to copy response header to an environment var


I am trying to chain some requests together by copying some data from an API call into the environment variables, using tests

I have written the following test. The first retrives a value from the JSON response body. this is working as expected.

The response header value however does not work.

This is the test I have written and below is a screenshot showing the test, the response header and the variables logged in the console

var jsonData = JSON.parse(responseBody);
pm.environment.set("form_instance_id", jsonData.id);
var resHeaders = pm.response.headers.get('Etag');
pm.environment.set("eTag", resHeaders.Etag);

Thanks in advance for your assistance.


So as soon as I posted this, I tweaked the test and it worked :man_facepalming:

I removed the .Etag from the β€œpm.environment.set(β€œeTag”, resHeaders.Etag);”


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.