Token value fetched from findbetween is getting changed automatically in next request

I am trying to pass my token value as it is but while fetching it , it is coming like this:

INFO[0004] {“ticket”:“YG26kRaQrN3y6Y3qyOVHTfvh/jjx1ZPOEadKe58nH/vzcyhbCCOPKCk0wYp3trqsB+kuK0cooQt0ubF6swz20vWoeGPli4zaF9sXtwKgc9j6WnjjKMRSFQ==”} source=console

But while I am sending in next request it is getting changed automatically adding extra \ to the ticket.

INFO[0005] {“method”:“POST”,“url”:“https://xyz.text.com/example/cs.exe/api/v2/nodes",“headers”:{“Content-Type”:["multipart/form-data; boundary=286aca129b4c0d5ffd328f7f78098e94e5f3344f8aa326a9778cd6729e97”],“User-Agent”:[“k6/0.37.0 (https://k6.io/)”],“Otcsticket”:[“YG26kRaQrN3y6Y3qyOVHTfvh\/jjx1ZPOEadKe58nH\/vzcyhbCCOPKCk0wYp3trqsB+kuK0cooQt0ubF6swz20vWoeGPli4zaF9sXtwKgc9j6WnjjKMRSFQ==”]},"

how to avoid this extra \ slashes in next request ?

Hello @ShreeDash can you share code for more understand?

1 Like

const url = ‘https://xyz.xyz.com/OTCS/cs.exe/api/v1/auth’;
const payload =
{
username: ‘xyx’,
password: ‘xyz#123’,

};
const params ={
headers:{
accept: ‘application/json’,
‘content-type’: ‘application/x-www-form-urlencoded’,
‘user-agent’:
‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36’,
‘sec-ch-ua’: ‘“Not?A_Brand”;v=“8”, “Chromium”;v=“108”, “Google Chrome”;v=“108”’,
‘sec-ch-ua-mobile’: ‘?0’,
‘sec-ch-ua-platform’: ‘“Windows”’,
},
};

const res = http.post(url, payload, params);
const ticket = findBetween(res.body, ‘{"ticket":"’, ‘"}’);

    console.log(ticket);
    
    console.log(res.body);
    
    check(res, {
        'is authentication ': (r) => res.status === 200,
    });
    
    const headers = {
        'content-type': 'multipart/form-data; boundary=----WebKitFormBoundaryGLrfLj7AHCVoJz8p',
        origin: 'https://eimqaservice.lowes.com',
        referer:
          'https://xyz.test.com/OTCS/cs.exe?func=ll&objType=144&objAction=create&parentId=23066092&nextURL=%2FOTCS%2Fcs%2Eexe%3Ffunc%3Dll%26objid%3D23066092%26objAction%3Dbrowse%26sort%3Dname%26viewType%3D1',
        'upgrade-insecure-requests': '1',
        'user-agent':
          'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36',
        'sec-ch-ua': '"Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"Windows"',
    }
   const data = {
    parent_id: '23066092',
    type: '144',
    name:'checkdoc1232122',
    file: http.file(pdf, 'LoadingTicket_ORD654321.pdf'),
   };
    const response = http.post('https://xyz.zyx.com/OTCS/cs.exe/api/v2/nodes',data, {headers: {otcsticket:`${ticket}`}},{headers: headers});
  
    //console.log(JSON.stringify(response.request.headers));
         console.log(response.status);
      //  console.log(response.status_text);
      console.log(JSON.stringify(response.request));
       console.log(JSON.stringify(response.body));
    check(response, {
        'is upload ': (r) => response.status === 200,
    });

It is adding slashes in generated token automatically .

The ticket value while fetch from response is

Hello @ShreeDash Token generated has escape backslash form host server.

Hello @ShreeDash please confirm headers token received from server if is same as one sent by request.