0
大家好,我嘗試遠程調用Sitecore的項Web API未安裝 Sitecore的,不能夠從遠程計算機調用服務失敗。我從遠程計算機獲得403,但從Sitecore機器獲得響應200。Sitecore的項目的WebAPI遠程呼叫與403
下面是示例代碼段
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);
}
}
}
}
Hi Ayman 感謝您的回覆。做這些changes.My頁面的URL後我仍然得到下面的錯誤是http:// dpc1/Sitecore的/ API/SSC /項目/路徑=/Sitecore的/內容/家 到dpc1訪問被拒絕 您無權查看此頁面。 HTTP錯誤403 –
嗨艾曼我能夠訪問該頁面現在.Thanks您的答覆。之前我正在對錯誤的實例進行更改.. –