I'm working on a template that retrieves information via API. The API requires you to authenticate with user/password, and it sends back an API key that is to be appended to the headers of all subsequent requests. I have created an item to send the user/pass, and return the response headers as JSON. I am them trying to use a Discovery LLD, to parse this reply and save the API key as a macro, to be used in all further requests. When testing the JSONPath used to parse the response (in preprocessing), I am getting the key I require, but when using this same path in LLD, I get an error.
JSON returned from item query:
Below is a similar response as above, just formatted to make it easier to digest:
JSONPath: $['header']['X-RestSvcSessionId']
Error: "Cannot find the "data" array in the received JSON object."
I've tried many iterations over the past 4 days, and cannot get this to work for the life of me. Can anyone assist?
JSON returned from item query:
Code:
{"header":{"HTTP/1.1 201 Created":"","Content-Length":"6492","Content-Type":"application/xml; charset=utf-8","Location":"https://x.x.x.x5:9398/api/sessionMngr/8af2d345-978f-44f2-93da-91bed0e98c6e","Server":"Microsoft-HTTPAPI/2.0","X-RestSvcSessionId":"OGFmMmQzNDUtOTc4Zi00OWXyLTkzXGEtOTFiZWQwZTk4YzZl","Set-Cookie":"X-RestSvcSessionId=OGFmMmQzNDUtOTc4Zi00OWYyLTkzZGEtOTFiZWQwZTk4YzZl; path=/api","Date":"Mon, 22 Aug 2022 15:35:28 GMT"}}
Code:
{"header":
{
"HTTP/1.1 201 Created":"",
"Content-Length":"6492",
"Content-Type":"application/xml; charset=utf-8",
"Location":"https://x.x.x.x:9398/api/sessionMngr/3e43de8c-229e-4b6d-8c62-164e4136a990",
"Server":"Microsoft-HTTPAPI/2.0",
"X-RestSvcSessionId":"M2UzM2RlOXMtMjI5ZS00YjZkLThXNjI tMTY0ZTQxMzZhOTkw",
"Set-Cookie":"X-RestSvcSessionId=M2UzM2RlXGMtMjI5ZS00YjZkLThjNjItM TY0ZTQxMzZhOTkw; path=/api",
"Date":"Fri, 19 Aug 2022 18:14:27 GMT"
}
}
Error: "Cannot find the "data" array in the received JSON object."
I've tried many iterations over the past 4 days, and cannot get this to work for the life of me. Can anyone assist?
Comment