Hi guys,
I just started trying this nice tool, but I am having trouble creating a GET call. When I use http.request, I get an authorized reponse and when I use http.get, I get and bad resquest. I am passing a secretReader key as headers, but I am not able to get the expected reponse.
Using http.request(‘GET’, fullurl, { headers: { ‘X-Authorization’: readerSecretTest } }); doesn not seems to be passing the “readerSecretTest” key in the headers. I get status : 401
Using http.get(fullurl, { headers: { ‘X-Authorization’: readerSecretTest } }); seems to be passing “readerSecretTest” key, but I get status: 400 bad request.
Using Postman, I am ble to get the expected result.
I hope you can guide me with this problem.
This is my script:
import http from 'k6/http';
import { check, sleep } from 'k6';
const fullurl = 'url'
const readerSecretTest = '731';
const fullurl = 'https://test'
export let options = {
vus: 1,
iterations: 1,
duration: '5s',
ext: {
loadimpact: {
name: 'Testing loadZone',
distribution: {
frankfurtDistribution: { loadZone: 'amazon:de:frankfurt', percent: 100 },
},
},
},
};
export default function () {
let params = {
headers: {
'X-Authorization': readerSecretTest,
},
};
let res = http.request('GET', fullurl, params);
check(res, {
'Status was 200': (r) => r.status == 200,
});
console.log(`Headers: "${JSON.stringify(res.headers)}"`)
console.log(`Status: "${res.status}"`);
sleep(1);
}