Hello,
I am facing a very strange issue. I am developing some scripts with JavaScript which make use of the Zbx API to extract or update data. For a while they were working fine, but since recently I am facing a critical issue that all the API requests fail with this error:
The scripts are embedded in a webpage which is then executed in the browser. Now the really weird part is that the same API request executed with CURL or with Postman is working without any problems.
My scripts were using initially the JQuery Ajax methods to send the request but I've tried also with the JS Fetch API and the result is the same.
I am pretty sure the requests are correctly build.
And to give an example:
Request header:
Request body:
Any clues?? Eventually, could you suggest how to troubleshoot the API requests on the server side?
I am facing a very strange issue. I am developing some scripts with JavaScript which make use of the Zbx API to extract or update data. For a while they were working fine, but since recently I am facing a critical issue that all the API requests fail with this error:
Code:
{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "Invalid params.",
"data": "Not authorized."
},
"id": 1
}
My scripts were using initially the JQuery Ajax methods to send the request but I've tried also with the JS Fetch API and the result is the same.
I am pretty sure the requests are correctly build.
And to give an example:
Request header:
Code:
POST /zabbix/api_jsonrpc.php HTTP/2 Host: example.com User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0 Accept: */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate, br Referer: http://localhost:5050/ Content-Length: 73 Origin: http://localhost:5050 DNT: 1 Connection: keep-alive Sec-Fetch-Dest: image Sec-Fetch-Mode: no-cors Sec-Fetch-Site: cross-site TE: trailers Content-Type: application/json Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Pragma: no-cache Cache-Control: no-cache
Code:
{
"jsonrpc": "2.0",
"method": "host.get",
"id": 1,
"params": {
"output": "extend"
}
}
Comment