I was trying to create a web page for my company which requires me to get some data from Octopus. I tried to use JavaScript to make REST API calls. But I get an error “Failed to load resource: the server responded with a status of 404 (Not Found)”. The same API call works in postman, but returns an error in the browser. Below is the sample JavaScript code for reference. Please let me know if there is something I need to add or change to get the data.
I still get the same error “Missing required request header. Must specify one of: origin,x-requested-with” even after changing the SetRequestHeader to xhttp.setRequestHeader(“X-Octopus-ApiKey”, “API-abc123456789”, “origin”, “x-requested-with”); please let me know how to proceed.
Could you tell me which browser you are using to run this on?
I’ve done some further testing for this issue here.
The first thing that comes to my mind when I look at the code you have sent to me I’m not sure if this was done inside this forum, but the quote marks which are typically associated with java-script do not look like:
“x-requested-with”
but rather look like this:
"x-requested-with"
it’s a subtle difference which could cause an error.