Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Sharepoint Cross Domain Issue (Edge Browser)

$
0
0

I am trying to do post action from cross domain site and i am getting below

error: HTTP403: FORBIDDEN - The server understood the request, but is refusing to fulfill it.

Code:

var formDigest;
$.ajax({
    url: "http://abc.com/sites/abc/_api/contextinfo",
    type: 'POST',
    async: false,
    xhrFields: { withCredentials: true },
    headers: {"accept": "application/json;odata=verbose"
    },
    success: function (data) {debugger;
        if (data.d) {
            formDigest = data.d.GetContextWebInformation.FormDigestValue;  
        }
    },
    error: function (err) {debugger;
        alert(err);
    }
});

item=JSON.stringify({  
        __metadata:  
        {  
            type: "SP.Data.TestForCrossDomainIssuesListItem"  
        },  
        'Title': 'Testing from cross web app Site using Edge browser'
    });
$.ajax({  
    url: "http://abc.com/sites/abc/_api/lists/getbytitle('TestForCrossDomainIssues')/Items",  
    type: "POST",  
    data:item,
    xhrFields: { withCredentials: true },   
    crossDomain: true,
    contentType:'application/json',
    headers:  
    {  "Accept": "application/json;odata=verbose",  "Content-Type": "application/json;odata=verbose",  "X-RequestDigest": formDigest,  "X-HTTP-Method": "POST"  
    },  
    success: function(data, status, xhr)  
    {  
        console.log('in Success');
    },  
    error: function(xhr, status, error)  
    {   
        console.log('in Error' +status);  
    }  
});

I have added rewrite url as mentioned in below ref

https ://sharepoint.stackexchange.com/questions/246313/how-to-add-multiple-url-to-access-control-allow-origin-header-in-sharepoint-2013


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>