У меня есть следующий код C #, который я использую для POST в службу REST, работающую на ZEND php.Это код, который я использую для публикации
string[] results = null;
System.Net.WebRequest req = System.Net.WebRequest.Create(url);
//set the method and content type
req.ContentType = "application/xml";
req.Method = "POST";
//set the data
byte[] bytes = System.Text.Encoding.Unicode.GetBytes(requestXML);
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length); //Push it out there
os.Close();
System.Net.WebResponse resp = req.GetResponse();
if (resp == null) return null;
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
string result = sr.ReadToEnd().Trim();
return (results);
, это XML-файл
<?xml version=\"1.0\"?>
<Root> <request> <APIClientID>4</APIClientID> <Version>0</Version>
<APIPassword>A564942C8BF7999A42F564B6EC52AEEF0F03D7DC</APIPassword> <Function>TransAPIStats</Function>
<Params> <Client>testClient</Client>
<Page>0</Page> <Application>hrblock-cb</Application>
<Function>ecb</Function>
</Params>
</request>
</Root>
Однако он говорит, что я
<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root><Status0>Error</Status0>
<Description0>Your POST data was empty. You need to submit an XML or JSON string
with the proper parameters.</Description0></root>\n