我收到了一个错误,并按照我收到的关于如何编码我的请求的 API 手册进行操作。下面是我的要求..
string url = "[My url to send request to]";
string xmlrequest = "<serv_request><head><securityContext><account>[account]</account><key>[my account key]</key></securityContext></head><body><username>[my user name]</username></body></serv_request>";
NameValueCollection nvc = new NameValueCollection();
nvc.Add("xml", Server.UrlEncode(xmlrequest));
WebClient client = new WebClient();
byte[] byteresponse = client.UploadValues(url, nvc);
string xmlresponse = client.Encoding.GetString(byteresponse);
我收到了错误的回复。在文档的顶层无效。
编辑..添加提供给我的 API 手册中的说明..
string url = " http://[domain_name]/_gateway/api/[filename].asp";
// formulate the XML request here
string xmlrequest = "<serv_request>...</serv_request>";
NameValueCollection nvc = new NameValueCollection();
nvc.Add("xml", Server.UrlEncode(xmlrequest));
WebClient client = new WebClient();
byte[] byteresponse = client.UploadValues(url, nvc);
string xmlresponse = client.Encoding.GetString(byteresponse);