Editor-based Rest Client - Request body isn't send
Answered
Hi I have a spring REST-API and I want to test it.
My problem is that the json body isn't send.
This don't work.
POST http://localhost:8080/player
Content-Type: application/json
{
"name": "Test",
"password": "123456"
}
But this works:
POST http://localhost:8080/player
Content-Type: application/x-www-form-urlencoded
name=Test&password=123456
I don't know why the first example doesn't work.
Anyone an idea?
Thanks
Please sign in to leave a comment.
Hello,
Works fine on my machine. There is similar request on YouTrack: https://youtrack.jetbrains.com/issue/WI-26113. Please try to reproduce the issue with new sample project. Will you get the same result with online service:https://requestbin.fullcontact.com/ ?
I get the same result with a new sample project.
I also delete the .idea folder and reopen the project but no success.
But a POST request with the online service works fine.
If it works with online service then body is actually sent. How did you check what request your application get?
I get a standard spring exception:
{
"timestamp": 1524148189504,
"statusCode": 500,
"error": "INTERNAL_SERVER_ERROR",
"exception": "MissingServletRequestParameterException",
"message": "Required String parameter 'name' is not present",
"path": "uri=/player"
}
That's why I think the request body doesn't arrives.
Does your application accept json content? have you tried to debug it and check full request data?
Oh your absolutely right.
I defined my parameters as RequestPram and not as RequestBody.
Thanks a lot and sorry for wasting your time.
No problem! You are always welcome!