Complete the code to add a custom header named 'Authorization' with value 'Bearer token123' in Postman.
pm.request.headers.add({ key: 'Authorization', value: '[1]' });The correct header value format for authorization is 'Bearer token123'.
Complete the code to check if the request header 'Content-Type' is set to 'application/json' in Postman test script.
pm.test('Content-Type is JSON', () => { pm.expect(pm.request.headers.get('Content-Type')).to.eql('[1]'); });
The 'Content-Type' header should be 'application/json' to indicate JSON data.
Fix the error in the code to correctly set the 'Accept' header to 'application/xml' in Postman pre-request script.
pm.request.headers.upsert({ key: 'Accept', value: '[1]' });The 'Accept' header should be set to 'application/xml' to request XML response.
Fill both blanks to add a header 'Cache-Control' with value 'no-cache' and verify it in a test script.
pm.request.headers.add({ key: '[1]', value: '[2]' });
pm.test('Cache-Control header is set', () => { pm.expect(pm.request.headers.get('Cache-Control')).to.eql('no-cache'); });The header key must be 'Cache-Control' and the value 'no-cache' to disable caching.
Fill all three blanks to create a test that checks if the 'User-Agent' header contains 'PostmanRuntime'.
pm.test('User-Agent contains PostmanRuntime', () => { const userAgent = pm.request.headers.get('[1]'); pm.expect(userAgent).to.include('[2]'); pm.expect(typeof userAgent).to.eql('[3]'); });
The header key is 'User-Agent', the value to check is 'PostmanRuntime', and the type of the header value is 'string'.