'Unauthorized request' and 'Can't determine Application ID from request' error when trying to contact endpoint using dojo/request/xhr
Original Publishing Date:
2020-01-22
Symptoms
I've created a service with custom operation. When i'm trying to contact it from my custom UI using dojo/request/xhr I get this error:
RequestError: Unable to load /aps/2/resources/81dc8c62-368f-4880-a740-a96bc9c7f14d/getList status: 403 Unauthorized request
In poa.debug.log:
Oct 2 12:16:33 sandbox : DBG [SYSTEM 1:1777:b0376b70 SAAS]: [APSC] Can't determine Application ID from request
Oct 2 12:16:33 sandbox : ERR [SYSTEM 1:1777:b0376b70 SAAS]: [APSC] REST Error: GET /aps/2//resources/81dc8c62-368f-4880-a740-a96bc9c7f14d/getList code=403: Unauthorized request
Cause
Every request to controller should specify custom headers, including APS-Token and application instance ID. If either of these headers is missing in request headers APS controller will refuse to process such request.
dojo/request/xhr
is a method from dojo library that does not provide any additional headers.
Resolution
Use aps/xhr
instead.
It sends a request using XMLHttpRequest with the given URL and options. It is the same as dojo/request/xhr
except it adds custom APS headers to HTTP requests and sets the 'handleAs'
parameter to 'JSON'
.
Internal content