【发布时间】:2012-02-03 21:41:39
【问题描述】:
我正在尝试使用 C# 连接到 REST API。 我能够成功执行一些 GET 请求,但 POST 一直给我 401 身份验证错误。
我已经下载了 fiddler,这就是我的请求的样子:
获取(作品)
请求标头
GET https: //hello.myurl.com/api HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Accept: application/xml
Authorization: Basic ***************************************************************************************************
Host: hello.myurl.com
-
POST(不起作用)
请求标头
POST https: //hello.myurl.com/api HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Accept: application/xml
Authorization: Basic ***************************************************************************************************
Host: hello.myurl.com
Content-Length: 12
请求正文
status=hello
(* 两者使用
相同String authinfo = "username:password";
Convert.ToBase64String(Encoding.ASCII.GetBytes(authInfo));
有什么想法吗?
【问题讨论】:
-
网络服务是你写的还是别人写的?从您所说的看起来好像某些方法对它们进行了身份验证
-
但我正在发送身份验证详细信息。
标签: web-services authentication rest curl