**In the tests there is a need to use “postRequest” but there are required headers for that request. For the current headers are set variables **
This is the example, but does not work:
const postRequest = {
url: ${pm.variables.get('url')}://${pm.variables.get('host')}/${pm.variables.get('path_prefix')}/v2/example/add
,
method: ‘POST’,
header: {
‘Content-Type’: ‘application/json’,
’User’: ‘{{user}}’,
’id’: '{{id}}'
},
body: {
newId: ‘{{newID}}’,
raw: JSON.stringify({ key: ‘this is json’ })
}
};
pm.sendRequest(postRequest, (error, response) => {
console.log(error ? error : response.json());
});
My question:
- How can use the already set variables as a Header value in the “postRequest” ?
- How can use the already set variables as a Body key’s value in the “postRequest” ?
Details (like screenshots):
How I found the problem:
I’ve already tried: