Hi guys. I'm in trouble once more :).
I'm trying to implement a POST method in my REST Api service. Here's the code:
@rootPathFromName
public interface IWeb
{
@path("/authenticate") @method(HTTPMethod.POST) @bodyParam("credential", "credential")
string authenticate(Credential credential);
}
public string authenticate(Credential credential)
{
return credential.username ~ "\t" ~ credential.password;
}
However, when I try to POST the following JSON:
{
"username": "Dato",
"password": "asd"
}
I get an error saying "Missing parameter credential".
Then I tried this:
"credential":
{
"username": "Dato",
"password": "asd"
}
but now I get "The request body must contain a JSON object with an entry for each parameter.". Any idea what's wrong with the code? I use application/json as a Content-Param value.
Thanks :)