x

AJAX request to Square API generates OPTIONS request, which fails

I'm trying to get started using the square API, and I'm running into trouble with GET requests.  Sending a simple GET request, such as the one in the "Getting Started" example  (https://connect.squareup.com/v2/locations) works fine via curl or the example python script.  However, when I try it in my own code using an AJAX method, an OPTIONS request is first sent to the Square server, before the GET request.  This is correct according to CORS which specifies OPTIONS requests be sent when you set a custom header in your GET request, such as the one that the Square API requires:

 

Authorizatio: Bearer ...

 

The problem is that the Square API rejects this OPTIONS request.

 

So, where to go from here?  Anyone have any ideas?

 

 

559 Views
Message 1 of 1
Report
0 REPLIES 0