Code-Please Click here在控制檯應用程序
使用的API權杖主要消費網絡API我有網絡API RESTful服務API密鑰,該密鑰使用我會得到的Web API服務的所有員工Redcords。
我會嘗試使用控制檯應用程序,但不會消耗。
URL - https://api.staging.Emp.com/api/provider/GetEmployee。
請幫我提出一些想法。
Code-Please Click here在控制檯應用程序
使用的API權杖主要消費網絡API我有網絡API RESTful服務API密鑰,該密鑰使用我會得到的Web API服務的所有員工Redcords。
我會嘗試使用控制檯應用程序,但不會消耗。
URL - https://api.staging.Emp.com/api/provider/GetEmployee。
請幫我提出一些想法。
您應該將Authorization
標頭的值爲Bearer <api-token>
添加到您的請求中。
例如,你可以使用此代碼
var request = WebRequest.Create("https://api.staging.Emp.com/api/provider/GetEmployee") as HttpWebRequest;
request.Method = "GET";
request.Headers.Add(HttpRequestHeader.Authorization,"Bearer <api-token>"); //example: "Bearer F4dfghuhgudhfgJL3"
// Get response here
var response = request.GetResponse() as HttpWebResponse;
if (response.StatusCode == HttpStatusCode.OK)
{
// ....
}
顯示錯誤,底層連接已關閉:發送時發生意外錯誤。 –
我在我自己的一臺服務器上測試了代碼,它工作正常。該錯誤涉及其他事情。你能告訴我更多細節嗎? –
其實我必須從我的.net web api上消費一個第三方api。這個第三方API是基本認證的。我可以通過一個控制檯應用程序來使用這個API。但是當我試圖從獲得401未授權 –
URL是保密的,這就是爲什麼我不能提到原始地址。 –
其實我試過postman exe使用檢查天氣url是正確的還是not.url是正確reterive的記錄also.but使用基本authuntication。 –