Posts

Showing posts with the label JSON

REST call returns XML instead of JSON in SharePoint

Image
Hi All, enforce REST call to return JSON format instead of #document(XML). $.ajax({         url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/currentuser",         type: "GET",         contentType : "application/json",         headers: { "Accept": "application/json; odata=verbose" },             success: function (data) {                     console.log(data);             custUser = data.d;         },         error: function (error) {             alert(JSON.stringify(error));         }     }); we would get the problematic output like below: add the these lines in "beforeSend" method $.ajax({         url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/currentuser",         type: "GET",         contentType : "application/json",         headers: { "Accept": "application/json; odata=verbose" },         beforeSend: function (XMLHttpRequest) {