jadrissi
(DRISSI)
October 24, 2022, 7:36pm
1
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 :
w4dd325
(w4dd325)
October 24, 2022, 8:28pm
2
Hi @jadrissi
You could save the value returned in the header as a variable and then use slice to remove characters as needed.
Example;
let URL = 'https://cam.uat.commercial.io/https:/cam.uat.commercial.io/v0/P221333/info';
console.log(URL.slice(62, -5));
Output;
OR …
You could use a RegEx
Example:
let URL = 'https://cam.uat.commercial.io/https:/cam.uat.commercial.io/v0/P221333/info';
var array = new RegExp("/v0/(.*?)/info").exec(URL);
if(array!=null && array.length>0 && array[1]!=null){
//pm.globals.set("secret", ""+array[1]);
console.log(array[1]);
}
Output:
jadrissi
(DRISSI)
October 24, 2022, 8:32pm
3
Hi @w4dd325 thank you so much I will try it and let you know
jadrissi
(DRISSI)
October 25, 2022, 4:54pm
4
Thank you very much it works fine
1 Like
system
(system)
Closed
August 31, 2023, 3:21pm
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.