cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UNKNOWN_METHOD_ERROR in HTTP monitor

kimberly_mirkes
Participant

In every http monitor, my first call is always to get an auth token. This step works fine. I pass it in the second step as the 'jwt' in the pre-execution step.

In two of my http monitors however, I also need to pass another  header in pre-execution called ###-Api-Key. I have to pass the request body to that call. That is my jsonData being stringified, then passed to const hash. That's then returned and added to the api.addHeader.

I'm always getting the error UNKNOWN_METHOD_ERROR so hoping someone can take a look at this pre-execution script I've written, and help me get past this issue.

(Certain items changed for secure reasons)

Pre-execution script:

const jsonData = [
{
"messageType": "welcome",
"context": "urn:com:33333",
"messageTypeCode": 62,
"sendSMS": true,
"sendEmail": false,
"smokeTest": true,
"bypassConsent": {
"countryCode": "+1",
"mainNumber": "3142083329"
},
"referenceDetails": {
"referenceType": "Agree",
"referenceNumber": "33333",
"driverDetails": {
"firstName": "B",
"lastName": "N",
"communicationPreference": {
"locale": "en_US",
"source": "Location"
}
},
"dateTime": "2023-01-17T04:29:00Z",
"brandCode": "##",
"brandName": "### ### ###"
},
"locationDetails": {
"group": "0000",
"groupnumber": "00000",
"groupemail": "",
"timeZone": "America/Chicago",
"locationPrettyName": "City",
"preferredLanguage": "en",
"phone": {
"countryCode": "+1",
"mainNumber": "2444444444"
}
}
}
];
 
api.setVariable("requestData", JSON.stringify(jsonData));
 
const TEST = 'LLLL';
const callingAppHeader = api.getHeader('###-Calling-Application');
 
let apiKey;
if (callingAppHeader && callingAppHeader.toLowerCase() === TEST.toLowerCase()) {
  const key = 'kdjflkadiowejfjkldfjs;kdlfj'; 
  const hash = CryptoJS.HmacSHA256(api.getValue("requestData"), key);
  apiKey = CryptoJS.enc.Base64.stringify(hash);
} else {
  apiKey = "Bearer " + api.getValue("jwt"); //jwt token from first step of this http monitor
}
 
api.addHeader('###-Api-Key', apiKey);
request.addHeader("Authorization", apiKey);

 

When looking at the execution details for more info on this error, I only get this:

//request

[
{
"requestId": "HTTP_CHECK_STEP-alpha-numericInfo",
"requestName": "send welcome message",
"sequenceNumber": 2,
"url": "",
"method": "",
"requestBody": "",
"requestHeaders": []
}
]

//response

[
{
"responseHeaders": [],
"responseBody": "",
"responseMessage": "",
"responseStatusCode": 0,
"responseSizeInBytes": 0,
"responseBodySizeLimitExceeded": false,
"failureMessage": ""
}
]

//execution

[
{
"visitId": "numericInfo",
"resolvedIps": [],
"healthStatusCode": 18,
"healthStatus": "UNKNOWN_METHOD_ERROR",
"peerCertificateDetails": "",
"redirectsCount": 0,
"peerCertificateExpiryDate": 0,
"processingMode": "STANDARD"
}
]

0 REPLIES 0

Featured Posts