How to use custom headers and user define tags together

When I pass the tags argument next to the URL or payload on an HTTP call. We can able to filter the results with tags but we missing the custom header value on the request.

let res = http.get(${BaseURL}/,{tags: { myTransaction: ‘JP_01_HomePage’ }},homePageHeader);

When I switch the header and tags argument like below.

let res = http.get(${BaseURL}/images/2016/jacarandaplus.png,homePageHeader,{tags: { myTransaction: ‘JP_01_HomePage_Image’ }});

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36

Now we missed the tag but got the header on the HTTP request.

Guide me on how to use both custom header and user-defined tags with the same HTTP call

you can do something like this:
{
method: ‘GET’,
url: ‘some url’,
params: {
headers: {
Authorization:Bearer ${token},
‘Content-Type’: ‘application/json’,
},
tags: { request_name: ‘get url’ },
},
},

1 Like

@aakash.gupta

Use Case :
If I introduce a “params” to wrap the header and tags, then I need to create a lot of unique params. For me, a set of requests has the same header values but different user-defined tags. Because it’s a web application, not an API request. How to handle that situation

const header = {
header1: ‘header value’,
header2: ‘header value’
}

const request1 = {
method: ‘GET’,
url: ‘some url’,
params: {
headers,
tags: { tag1: ‘tag1 value’ },
},
};

const request2 = {
method: ‘GET’,
url: ‘some url’,
params: {
headers,
tags: { tag2: ‘tag2 value’ },
},
};

1 Like