Hi
I have some troubles with the pm.sendRequest. I read thats not supported by the k6 but I have no idea how can I change that part of a code. How can I do that to make it work ? Here it is:
const tokenUrl = 'https://qa-appgw.reykjavik.is/gateway/IdentityServer/1.0/connect/token';
const clientId = 'postman-api';
const clientUser = 'SYS_THJODSKRA_TEST';
const scope = 'thjodskra_api';
const getTokenRequest = {
method: 'POST',
url: tokenUrl,
header: [
{ key: 'x-Gateway-APIKey', value: pm.collectionVariables.get("QA-IDENTITY-SERVER-KEY") }
],
body: {
mode: 'formdata',
formdata: [
{ key: 'grant_type', value: 'client_credentials' },
{ key: 'client_id', value: clientId },
{ key: 'client_secret', value: pm.collectionVariables.get("clientSecret") },
{ key: 'user', value: clientUser },
{ key: 'scope', value: scope }
] }
};
pm.sendRequest(getTokenRequest, (err, response) => {
const jsonResponse = response.json();
const newAccessToken = jsonResponse.access_token;
pm.variables.set('access_token', newAccessToken);
});