Reputation: 133
Hi All I am trying to call the SiteCore Item Web API remotely where Sitecore is not installed and not able to call the service from remote machine. I am getting 403 from remote computer but getting response 200 from Sitecore machine.
Below is sample code snippet
namespace SiteCoreApi
{
class Program
{
static void Main(string[] args)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create ("http://dpc/sitecore/api/ssc/item/?path=/sitecore/content/home");
request.Headers["X-Scitemwebapi-Username"] = @"sitecore\admin";
request.Headers["X-Scitemwebapi-Password"] = "b";
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.Write(String.Format("Content length is {0}", response.ContentLength));
Console.Write(String.Format("Content type is {0}", response.ContentType));
// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream();
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
Console.Write("<br /> Response stream received. <br />");
Console.Write(readStream.ReadToEnd());
Console.ReadLine();
}
catch(Exception ex)
{
Console.Write(ex.Message);
}
}
}
}
Upvotes: 2
Views: 2916
Reputation: 1255
I think that happens because the sitecore services security policy is set by default to ServicesLocalOnlyPolicy
, and you need to change it to ServicesOnPolicy
you can find those configurations under :
App_Config/include/Sitecore.Services.client.config, but be careful Changing the settings in this file may impact the security of your Sitecore installation
Upvotes: 5