DEV Community

Discussion on: Testing your API with REST Client

 
techwatching profile image
Alexandre Nédélec

In my example you can just change the value of the planetName variable. You can also do not use local variable and set environment variable in your vs code settings (rest-client.environmentVariables)

Thread Thread
 
noble47 profile image
Noble-47

Just came across your article and it was really helpful. But I still don't understand how to pass parameters in POST request

Thread Thread
 
techwatching profile image
Alexandre Nédélec

I have written an example in a response to a comment above.
You can do something like the following. Here I am defining a variable @test with a value of HELLO and using this parameter in my POST request.
@test is your parameter, you just have to change its value to pass a different value in your request.

### Second request using a variable 
@test = HELLO
POST https://jsonplaceholder.typicode.com/posts
Content-Type: application/json

{
    "userId": 1,
    "title": "TEST ",
    "body": "TEST body {{test}}"
}
Enter fullscreen mode Exit fullscreen mode