Sending data to a website using Tests in GET request

Hello, I need to send data to a website through GET request. I set the variables as environment variables and pulled them out using “Pre-request Script” field:


I need to use those values to update fields on the website.
I used this as my code to refer to them for changing,

    "clientId": "{{clientId}}",`
    "userId": "{{userId}}",
    "time": "{{time}}",
    "serviceTypeId": "{{serviceTypeId}}"

but I get **412Precondition Failed** error when I send out my request and nothing is changed on the website. I have my AUTH key set and other requests work fine.

Here’s what I get in console.

Hi @illusorydannyboy,

Thanks for the screenshots and the level of detail you have provided.

To start off, for the variable resolution in the body, you do not need to use pm.environment.get().... That is only required when you are working with that variable in the same scope of the Pre-Request tab.

The curly brace notation you used, such as {{clientId}}, will suffice.

Now for the issue you are seeing. Generally in a GET request, you are not allowed to set the body, and thats because generally a server does not expect for there to be a request body in a GET request. Its standard behavior. Even when you set the request to GET in postman, it will auto default to no body. GET requests are about receiving or “getting” data, so it doesn’t expect to receive or persist and will throw an error.

Being a 4** error, you are seeing that because its a client side error, meaning something in the request was incorrect. Its a 412 “Precondition Failed”, because the server expects to receive an empty request body, so that “precondition” failed.

In order to actually put in the data into the HTML or the website, you would want to use something like Selenium web driver, which will have to be scripted out. Refer to the link below for more information.

This is not something you cannot do inherently in Postman.

However, there are other tools that make this a bit easier, such as Katalon, where you can record your screen an input the data you desire into your UI/HTML (the one you are trying to send in the request body)

Let me know if this makes sense and if you have any more questions.

Hope this helps!


1 Like

Thanks for the reply, but I specifically need to implement it through POSTMAN tools. I should’ve pointed out that in my original question.

Hi @illusorydannyboy,

You’re welcome. However, the way you would like to accomplish what you are doing is not possible in Postman.

To be more clear, what is it exactly you are trying to accomplish?

Are you trying to simulate data being sent to a website? Is there a backend API that correlates with this page? Is there a POST request that resembles the values you want to input?

If we can get a better picture of what your end goal is, we may be able to find a way to do it in Postman.