Sharepoint Cross Domain AJAX

Copper Contributor

I need to execute CrossDomain REST Request (AJAX) on Sharepoint REST API, and get content as result of this request. My script executed on Browser (Chrome) on wich I logged on Sharepoint.

 

CODE EXAMPLE

     

// Load the required SharePoint libraries

          $(document).ready(function () {

                                                $.ajax({

                                                                method: "GET",

                                                                headers: { "Accept": "application/json; odata=verbose" },

                                                                cache: false,

                                                                async:false,

                                                                url: "https://LINK_TO_SITE.sharepoint.com/_api/lists/getbytitle('Kunde')/items?$expand=Folder",

                                                                data: "",

                                                                contentType: "application/jsonp; charset=utf-8",

                                                                dataType: "jsonp",

                                                                processData: true,

                                                                crossDomain: true,

                                                                success: function (data, status, jqXHR) {

                                                                console.log(data);

                                                                },

                                                                error:function (data, status, jqXHR) {

                                                                console.log(data);

                                                                }

                                                });

                                });

 And Have this error

  

AtomXML.PNG

 

If change dataType: "jsonp" to dataType: "json", get next error

 

403.PNG

 

This Page I publishing on the Dynamics CRM site as WebResource

 

Maybe some of you have a decision?

0 Replies