2014-09-24 1 views
0

나는이 문서에 따라 다음 POST 요청을 보내고 :ServiceStack UserName은 비워 두지 않아야합니다.

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":[...] 

왜 내 사용자 이름과 암호가 비어 생각합니까?

Ref. https://github.com/ServiceStack/ServiceStack/wiki/Authentication-and-authorization

답변

1

HTTP 헤더에 있어야 요청의 Content-Type, 시도 :

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 
} 
+1

당신은 너무 맞아! 고마워, 나는 그걸 잊어 버렸다. 내 실수. – user1477388

+0

그건 그렇고, 의사와 이야기하기는 어렵지만 어떻게 SessionId를 돌려 보낼 수 있습니까? GET 요청의 헤더를 통해 전송하려고 시도했지만 여전히 401 권한이 없다고 말합니다. – user1477388

+0

또한 AppHost에서 플러그인으로 정의 했더라도 디버깅 할 때 TryAuthenticate 메소드가 작동하지 않는다는 것을 알았습니다. http://stackoverflow.com/questions/17634486/401-error-using-authenticate-basicauthprovider에 따라 맞춤 속성을 만들어야합니까? – user1477388