How to call cross domain rest call using SharePoint rest API 2013
posting data in SharePoint list from https://qa.sp.scb.org/en/whoweare/diversity/Pages/Admin.aspx
To
http://qa.sp.scb.org/fr/whoweare/diversity/_api/web/lists/GetByTitle('CurrentTheme')/items(2)",
getting Error -Response to the preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://qa.sp.scb.org' is therefore not allowed access. The response had HTTP status code 401.
Code-
function AddListItemFrench()
$.ajax({
url: "https://qa.sp.scb.org/fr/whoweare/diversity/_api/web/lists/GetByTitle('CurrentTheme')/items(2)",
type: "POST",
data: JSON.stringify({
__metadata: {
type: "SP.Data.Current_x0020_ThemeListItem"
},
Title: setTitle,
ThemeTitle: ThemeHeading,
Image: setImage,
BgImage: setbgImage,
Tag: hashtag,
RightTheme: RightmenuHasTag,
HashtagTitleFrench:Hashtagfrench,
ThemeTitleFrench:Themetitlefrench
}),
headers: {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*",
"X-HTTP-Method": "MERGE"
},
success: function(data, status, xhr) {
console.log(" Theme update in French version");
$("#slectedtheme").text(setTitle);
},
error: function(xhr, status, error) {
console.log("AddListItem is not update");
}
});
}