0

We have (02) SharePoint farm in different domain and they are connected.

We need to access data from Farm-A SharePoint List in Farm-B using Rest-API

usually we calling REST API by just URL as below when in same domain. But when domain is different what can we do?

https://mysharepoint.com/_api/web/lists/getbyTitle('Events')/items 
?$top=1 
&$select=Title,Description,Date 
&$filter=ID eq 12

1 Answer 1

0

For cross domain call, You can use SP.AppContextSite

Example:

appContextSite = new SP.AppContextSite(ctx, spHostUrl);

Nweb = appContextSite.get_web();
ctx.load(Nweb); 

REST:

Now your rest url will be like below,

var url = appwebUrl + "/_api/SP.AppContextSite(@target)/web/lists/getbyTitle('Events')/items?$top=1&$select=Title,Description,Date&$filter=ID eq 12&@target='" + hostwebUrl + "'";

For refer in details, you follow this link and this link

If you find this answer as useful, upvote it.

5
  • How should I pass the credentials? Commented Nov 16, 2017 at 7:03
  • Not required, same user must have access of another domain's site.
    – Anil Pal
    Commented Nov 16, 2017 at 7:47
  • how domain1\user1 added in another domain? I mean how SharePoint find user1 in domain2? Commented Nov 16, 2017 at 8:17
  • User 1 is common for site, right? only domians are different?
    – Anil Pal
    Commented Nov 16, 2017 at 9:27
  • But domain is not same doamin1\user1 and doamin2\user1. Commented Nov 18, 2017 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.