I'm facing the problem with sending request body as raw text without quotes.
The content type of request should be text/uri-list.
Sending it in Postman works correctly but when I try to implement the same operation in java it does not work.
I'm using feign as api client.
Client definition of endpoint looks like this
@RequestLine("PUT /someEndpointOne/{id}/someEndpointTwo")
@Headers("Content-Type: text/uri-list")
JSONObject addSomethingToSomething(@Param("id") String id, @RequestBody okhttp3.RequestBody uri);
And I use it in test like this:
somethingClient.addSomethingToSomething("1", okhttp3.RequestBody.create(okhttp3.MediaType.parse("text/uri-list"), "http://localhost/someEndpointTwo/1"))
Instead of sending raw data it actually sends empty object:
PUT http://localhost/someEndpointOne/1/someEndpointTwo HTTP/1.1
Content-Type: text/uri-list
Content-Length: 2
{}
END HTTP (2-byte body)
what causes bad respone.
I would be grateful for help with solving this problem.
The following works for me:
Where
@PutMappingcomes fromorg.springframework.web.bind.annotation.PutMappingand@PathVariablecomes fromorg.springframework.web.bind.annotation.PathVariable.