How to get data from header 'location'

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

Here’s an outline with best practices for making your inquiry.

My question:
My issue is that I want to extract an url from header response (location): the response show 2 times the same url: exp: https://pro.uat.test/https:/cam.testcase/test/

Details (like screenshots):

How to get only thr second part of the header response : https:/cam.test.testcase/PRODUCR221333
Or only the id PRODUCR221333 ?

How I found the problem:

Is there a solution ? Many thanks
I’ve already tried:

Hi @jadrissi

You could save the value returned in the header as a variable and then use slice to remove characters as needed.


let URL = '';
console.log(URL.slice(62, -5));


OR …

You could use a RegEx


let URL = '';
var array = new RegExp("/v0/(.*?)/info").exec(URL);
    if(array!=null && array.length>0 && array[1]!=null){
        //pm.globals.set("secret", ""+array[1]);


Hi @w4dd325 thank you so much I will try it and let you know

Thank you very much it works fine :ok_hand:

1 Like

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