0

We have two sharepoint farms in same company network

  1. http://farm1 (Internet anonymous sharpoint site)
  2. http://farm2 (Intranet sharepoint site)

Farm1 has a list called list1 under one of the site collection.

We have a site page under one of the site collection of Farm2 and requirement is to the data from list1 on this webpage under farm2.

What are our options?

  1. Can we use REST calls, if cross site scripting is going to be issue, is there any way to avoid it and still use REST calls

  2. Our worst case option is to recreate list through task scheduler every night on Farm 2 using the template from list1.

  • what about inserting a webpage viewer web part? – teylyn Jan 9 '17 at 6:11
  • Thanks Teylyn, however Data will be processed to show in the custom interface (jquery datatble ) once received on the webpag. – Rohit Jan 9 '17 at 6:37
0

Try to use the SharePoint Client Object Model: you can create C# code that runs outside of the context of the farm being accessed.

0

You can use C# for this, Below is the code to connect to SharePoint and perform Rest Calls

//Get Request Digest
HttpWebRequestendpointRequest = (HttpWebRequest)HttpWebRequest.Create("<<site
url>>/_api/contextinfo");
endpointRequest.Method = "POST";
endpointRequest.Accept = "application/json;odata=verbose";
endpointRequest.ContentType = "application/x-www-form-urlencoded";
endpointRequest.ContentLength = 0;
NetworkCredential cred = newSystem.Net.NetworkCredential("username", "password", "domain");
endpointRequest.Credentials = cred;
HttpWebResponseendpointResponse = (HttpWebResponse)endpointRequest.GetResponse();
//Sample Post Command
HttpWebRequestendpointRequest = (HttpWebRequest)HttpWebRequest.Create("<<REST URL>>");
endpointRequest.Method = "POST";
endpointRequest.Accept = "application/json;odata=verbose";
endpointRequest.ContentType = "application/json;odata=verbose";
NetworkCredential cred = newSystem.Net.NetworkCredential("username", "password", "domain");
endpointRequest.Credentials = cred;
String username = "username";
String password = "password";
StringuserPassword = username + ":" + password;
byte[] byteArrayUP = Encoding.UTF8.GetBytes(userPassword);
endpointRequest.Headers.Add("Authorization", "Bearer" + byteArrayUP);
stringpostData = "{ '__metadata': { 'type': 'SP.Data.<<ListTitle>>ListItem' }, 'Column1':
'Text1','Column2':'Text2'}";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// endpointRequest.ContentLength = byteArray.Length;
endpointRequest.Headers.Add("X-RequestDigest", digest);
// Get the request stream.
StreamdataStream = endpointRequest.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
HttpWebResponseendpointResponse = (HttpWebResponse)endpointRequest.GetResponse();

https://www.dsouzajoel.com/2015/12/09/connect-to-sharepoint-on-premise-using-external-applications/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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