Alex Baban
Alex Baban

Reputation: 11732

POST request with the REST Client extension for Visual Studio Code

I'm using the "REST Client" extension for Visual Studio Code https://marketplace.visualstudio.com/items?itemName=humao.rest-client.

I'm able to make a GET request with this code:

GET https://some.domain.com/search/someuser/somekey?foo=5&bar=1

and it works.

Now, I need to make a POST request and pass the foo and bar values as form fields.

I tried with:

POST https://some.domain.com/search/
Authorization: Basic someuser somekey
Content-Type: application/x-www-form-urlencoded

'foo'='5'
'bar'='1'

but I'm getting back an error "Missing required parameter foo in the post body"

What is the correct syntax for a POST request with REST Client?

Thanks.

Upvotes: 3

Views: 8703

Answers (1)

Alex Baban
Alex Baban

Reputation: 11732

It works like this:

POST https://some.domain.com/search/
Authorization: Basic someuser somekey
Content-Type: application/x-www-form-urlencoded

foo='5'&bar='1'

  • parameters need to be concatenated with &
  • parameter names should not be put in between quotes

Upvotes: 4

Related Questions