我該如何更改WebClient請求的動詞?它似乎只允許/默認爲POST,即使在DownloadString的情況下。如何通過WebClient請求使用動詞GET?
try
{
WebClient client = new WebClient();
client.QueryString.Add("apiKey", TRANSCODE_KEY);
client.QueryString.Add("taskId", taskId);
string response = client.DownloadString(TRANSCODE_URI + "task");
result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(response);
}
catch (Exception ex)
{
result = null;
error = ex.Message + " " + ex.InnerException;
}
而且小提琴手說:
POST http://someservice?apikey=20130701-234126753-X7384&taskId=20130701-234126753-258877330210884 HTTP/1.1
Content-Length: 0
你正在做一些非常特別的地方 - [DownloadString](http://msdn.microsoft.com/en-us/library/fhd1f0sw.aspx)使用GET:「...對於HTTP資源,GET方法用來」。 –
奇怪的是,我覺得「下載」方法會使用GET。這是我請求的完整代碼。 – FlavorScape
你完全確定'WebClient'不是一個自定義類嗎? –