我的網絡請求後,我的網站響應內容長度總是似乎爲-1。我相信你的按摩和簽名是正確的。 我在這裏做錯了什麼?HttpWebResponse contentLength始終爲-1
string msg = string.Format("{0}{1}{2}", nonce, clientId, apiKey);
string signature = ByteArrayToString(SignHMACSHA256(apiSecret, StrinToByteArray(msg))).ToUpper();
const string endpoint = "https://www.bitstamp.net/api/balance/";
HttpWebRequest request = WebRequest.Create(endpoint) as HttpWebRequest;
request.Proxy = null;
request.Method = "POST";
request.ContentType = "application/xml";
request.Accept = "application/xml";
request.Headers.Add("key", apiKey);
request.Headers.Add("signature", signature);
request.Headers.Add("nonce", nonce.ToString());
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
這可以工作,因爲您不檢查Content-Length標頭。如果爲流創建StreamReader並將流讀到最後,您也可以使用HttpWebRequest進行此項工作。 –