0
JSON/XML數據時,我要求一個的WebAPI請求,我有錯誤,如期待JSON/XML數據期待中的WebAPI
try
{
string oRequest = _xml.UpdateInvereqxml(UserName, Password,OTAhotelid, Invy);
string uri = @"service/update";
System.Net.WebRequest req = System.Net.WebRequest.Create(uri);
req.Method = "POST";
req.ContentType = "text/xml";
System.IO.StreamWriter writer = new System.IO.StreamWriter(req.GetRequestStream());
writer.WriteLine(oRequest);
writer.Close();
System.Net.WebResponse rsp = req.GetResponse();
Stream istrm = rsp.GetResponseStream();
string StreamReader = new StreamReader(istrm).ReadToEnd();
}
如何解決上述錯誤? –
也許這個異常是由服務器引發的,因爲你發送了錯誤的內容類型。或者也許你錯過了正確的Accept Header – Templum