function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
UshankUshank 

Not able to able web service from JS

Hello Guys,

I am trying to call apex rest api from Jquery Ajax functional which is giving me unauthorized "400 error status" in return. I am setting the request header with session information "xhr.setRequestHeader('Authorization', "OAuth " + session);" as this.
When I am trying to call the webservice from Chrome rest console, workbench and Soap UI its working fine and giving me result back but I am only facing issue while trying to call this service from java script.
Could it be because of cross site scripting? 
Please suggest me how to proceed further.
 
ShashankShashank (Salesforce Developers) 
Couple of links which might help:
https://developer.salesforce.com/forums?id=906F0000000AzOwIAK
http://salesforce.stackexchange.com/questions/15480/salesforce-rest-api-example-error-failed-with-status-400