我有問題與身份驗證/授權發佈JSON ..以下是我的代碼..對手說,他們沒有收到標題...我不知道爲什麼...C#發佈JSON與身份驗證標題
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(stringData);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(serverURL);
req.Method = "POST";
req.ContentType = "application/json";
req.ContentLength = data.Length;
req.Headers.Add("Authentication", merchantID);
req.Headers["Authentication"] = merchantID;
Stream newStream = req.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
string returnString = response.StatusCode.ToString();
'Add(LoginName,LoginName)','Add(AuthenticationKey,AuthenticationKey)'etc看起來不對。錯過枚舉名稱? –
是的..第一個參數是這樣的枚舉名... –
EnumCollection.ServiceRequestHeader.AuthenticationKey.ToString(), –