我正在尝试从C#调用web api服务。以下是工作提琴手的踪迹。
POST https://clientsite.com/getAPI.json HTTP / 1.1
Content-Type:text / plain
user:user
密码:传递
键:键
主持人:clientsite.com
内容长度:63
期待:100-continue
连接:关闭
{ “的objectID”: “XXXXX”, “的objectType”: “YYYYY”}
============================================ 现在我写了以下代码...... HttpWebRequest req = HttpWebRequest)WebRequest.Create(@“https://clientsite.com/getAPI.json”);
req.Method =“POST”;
req.ContentType =“text / plain”;
string strNewValue =“login = user& password = pass& key = Key& objectID = XXXXXX& objectType = YYYYY”;
byte[] byteArray = Encoding.UTF8.GetBytes(strNewValue);
req.ContentLength = byteArray.Length;
Stream dataStream = req.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
我收到身份验证错误。显然它不喜欢我编写请求的方式。任何人都可以帮助提出像提琴手一样的确切请求吗?非常感谢帮助。