ServiceStack UserName不应为空?

时间:2014-09-24 14:58:09

标签: authentication servicestack

我按照文档发送以下POST请求:

POST http://localhost:56049/auth/credentials?format=json HTTP/1.1
User-Agent: Fiddler
Host: localhost:56049
Content-Length: 64

{
    "UserName" : "admin",
    "Password" : "test",
    "RememberMe" : true
}

然而,它给了我一个意想不到的结果:

{"responseStatus":{"errorCode":"ValidationException","message":"Validation failed: 
\r\n -- 'User Name' should not be empty.\r\n -- 'Password' should not be empty.",
"stackTrace":[...]

为什么我认为我的用户名和密码是空的?

参考。 https://github.com/ServiceStack/ServiceStack/wiki/Authentication-and-authorization

1 个答案:

答案 0 :(得分:1)

请求的Content-Type应位于HTTP标头中,请尝试:

POST http://localhost:56049/auth/credentials HTTP/1.1
Host: localhost:560490
User-Agent: Fiddler
Content-Type: application/json
Content-Length: 64

{
    "UserName" : "admin",
    "Password" : "test",
    "RememberMe" : true
}