I am trying to implement a simple recurly API client to create an account in recurly using a local HTML page for testing purposes.
I am hard-coding the request in Javascript and using XMLHttpRequest to do the post operation.
var client = new XMLHttpRequest();
client.open("POST", "https://subdomain.recurly.com/v2/accounts", true);
client.setRequestHeader("Authorization", "Basic " + "API Key");
client.send([XML Request Here]);
The code is returning 404.
But if I comment out
client.setRequestHeader("Authorization", "Basic " + "API Key");
The code is returning 401 (unauthorized), which means that the endpoint exists but there is a problem with setting the Authorization header.
Edit:I have checked the method for the 404 request and it is OPTIONS instead of POST, is that due to the same origin policy?
Any help is appreciated.
Thank you.