Huachao / vscode-restclient

REST Client Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=humao.rest-client
MIT License
5.32k stars 445 forks source link

vscode rest client extention sending content as octet-stream instead of json #959

Closed NooneXe closed 2 years ago

NooneXe commented 2 years ago

I have following rest service in java spring

@PostMapping("/create")
public void createstuff(@RequestBody @Valid SomeClass obj) {
   //some stuff
}

I can successfully send the obj json with curl and hoppscotch(similar to postman)

curl -X POST http://0.0.0.0:8080/create \ 
  -H 'Content-Type: application/json' 
  -d '{"field1" : "and its value"}'

same request made with hoppscotch also works

but this request

POST http://localhost:8080/create

content-type: application/json

{
    "field1" : "and its value"
}

made from vscode rest client does not works.

in spring terminal, I get follwoing:-

2022-01-14 17:01:45.303  WARN 26935 --- [nio-8080-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported]
AnWeber commented 2 years ago

There is no empty line between request line and headers

POST http://localhost:8080/create
content-type: application/json

{
    "field1" : "and its value"
}
Huachao commented 2 years ago
POST http://localhost:8080/create

content-type: application/json

{
    "field1" : "and its value"
}

@AnWeber is right, remove the blank line between request line and headers