0
有誰知道我可以張貼到tagpacker網站(在.NET中使用以下API?因爲不知何故,我不明白授權對他們的服務器...從C#連接到Tagpacker.com用的HttpWebRequest
目前我正在使用的代碼如下:
private readonly HttpWebRequest _httpWebRequest = (HttpWebRequest)
WebRequest.Create("https://tagpacker.com/api/users/{YourUserID}/tags");
public void Load()
{
_httpWebRequest.ContentType = "application/json";
_httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(_httpWebRequest.GetRequestStream()))
{
var json = "{\"user\":\"test\"," +
"\"password\":\"bla\"}";
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
var httpResponse = (HttpWebResponse)_httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
}
但我找回了以下消息:
{
"status": 401,
"message": "User not authorized",
"code": "USER_NOT_AUTHORIZED",
"url": "/unauthorizedHandler"
}
ŧ他只是你從他們那裏得到別的東西是一個「API訪問權限」如下代碼:1b3f314dd132b0015b5415b1:bd0ffe4b-a01e-4bf5-b1ed-12b24145d12d其中,第一部分是你用戶ID,第二個是你的API -code我猜?有沒有人有如何使用這個想法? Tagpacker's Api FAQs are here.