Forum Discussion
samudhraa
12 years agoExpert
Hi Shalini,
Few things that might be of help.
- I would recommend you to test the RESTcall using a REST client (chrome plugin , poster etc) , so that you would know the api , query parameters , data that should be given.
- I can see that you are authenticating , with a GET call , which is usually not the case. Generally , a POST call is used for authentication.
- Having said that , if you are doing a cross domain call , and handling it with jsonp , that would work only for GET call and not a POST call. You might have to think of an alternate solution for it. My suggestion would be , if you have control over the other end , to add the "access control allow origin" to the header of the method on server side.
Here is a sample ajax POST call that worked for me.
$.ajax({
url: 'http://blabla.k2.com/doSomething/',
type: 'POST',
data: data,
cache: false,
dataType: 'json',
processData : false, // Don't process the files
contentType: false, // Set content type to false as jQuery will tell the server its a query string request
success: function (data) {
console.log(data.UploadStatus);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log('Error is :' + errorThrown + '; ' + textStatus + '; ' + jqXHR.status);
}
});
I am sure you must have gone through this informative article on working with endpoints , but just in case.
Hope that helps.
Thanks,
Sam