Status: Open
Status: Answered
Status: Closed
Status: Duplicate

Content Server REST APis Cross-Domain AJAX

Posted Apr 29 by Patrick Vitali.
Updated Apr 29.

Hi, I am experiencing problems trying to consume CS REST Apis from a different domain.
I think the problem depends on the fact that whenever I try to send an auth request, the browser (correctly) sends a Cors OPTIONS request without parameters. As I see in the Builder, the REST APis code has been designed to handle correctly this kind of requests in ExecuteRequest method of RestApiRequestHandler. My problem is that I never reach that method because the CheckArgs function fails (there are no parameters in the OPTIONS request) and the Content Server returns me a 500 error code.
I haven't tried yet with the OTAG reverse proxy, do you think that I would obtain different results ?
Am I doing something wrong ?

2 Answers

BEST ANSWER: As chosen by the author.

Update: my fault I was setting contentType: 'application/json',in the Ajax request

BEST ANSWER: As chosen by the author.

Yes, empty content type for requests with the OPTIONS verb, please - they expect no data. The content type of for the request payload of POST and PUT requests has to be either application/x-www-form-urlencoded or multipart/form-data today; not the application/json either.

 You have subscribed and will receive email notifications of updates to this topic. To unsubscribe, uncheck the checkbox.


Related categories

Related tags

Your answer

To leave an answer, please sign in.