# How to set a var in a x-www-form-urlencoded request body?

**URL:** <https://community.postman.com/t/how-to-set-a-var-in-a-x-www-form-urlencoded-request-body/51520>\
**Category:** Help Hub\
**Tags:** variables, request, request-payload\
**Created:** [September 8, 2023, 1:31am UTC](https://community.postman.com/t/how-to-set-a-var-in-a-x-www-form-urlencoded-request-body/51520 "2023-09-08T01:31:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![wangjing0125](https://avatars.discourse-cdn.com/v4/letter/w/e0b2c6/32.png) [@wangjing0125](https://community.postman.com/u/wangjing0125)\
**Post date:** [September 8, 2023, 1:31am UTC](https://community.postman.com/t/how-to-set-a-var-in-a-x-www-form-urlencoded-request-body/51520/1 "2023-09-08T01:31:07Z")

</div>

I need to set variables in below request body.  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/a/aad50e265fc9e5a42873d57dc54a9cbcacbb401d.png)

and i tried the x-www-form-urlencoded like below, it is poping up ‘unsupported media type’.  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/4/0/40ab741e4d7ff1cb036b30b26365a2085859a924.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 8, 2023, 1:25pm UTC](https://community.postman.com/t/how-to-set-a-var-in-a-x-www-form-urlencoded-request-body/51520/2 "2023-09-08T13:25:55Z")

</div>

Hey @wangjing0125 👋

Welcome to the Postman Community! :postman:

Without knowing what that API expects as a payload type (Raw JSON, Form-Data, Etc) it difficult to give you a working solution. Could you share any documentation you might be following?

One method you could use to add variables into a request body is to create the structure and data in a pre-request script, save that as a variable and then reference this in your payload body.

If you’re able to expand on the details of the request, we’ll be able to help you further.

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [September 12, 2023, 1:40pm UTC](https://community.postman.com/t/how-to-set-a-var-in-a-x-www-form-urlencoded-request-body/51520/3 "2023-09-12T13:40:53Z")

</div>

Considering your first screenshots and that some elements are objects within object, I suspect this is raw\JSON.

Have you done through the Postman docs yet?

[Using variables | Postman Learning Center](https://learning.postman.com/docs/sending-requests/variables/)

As this is fairly straight forward. Store you values as collection or environment variables and then reference them in the body using double curly brackets. {{variableName}}.

If you are new to Postman, then I would suggest a visit to the Learning Centre.

[Overview | Postman Learning Center](https://learning.postman.com/docs/introduction/overview/)

Including the Postman Training links under “Other Resources”.

![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/b/3b763d56d66445f4c34eeb66c64631335559a741.png)

I would recommend the “Galaxy APIs 101” course first as it gets you used to the application features and the GUI.

Then the “Galaxy Testing and Automation” course which teaches you how to assert the responses. It includes defining and using variables from responses.

---

<div class="post-metadata">

**Author:** ![wangjing0125](https://avatars.discourse-cdn.com/v4/letter/w/e0b2c6/32.png) [@wangjing0125](https://community.postman.com/u/wangjing0125)\
**Post date:** [September 18, 2023, 8:40am UTC](https://community.postman.com/t/how-to-set-a-var-in-a-x-www-form-urlencoded-request-body/51520/4 "2023-09-18T08:40:51Z")

</div>

![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/d/ad25a1719ac0716e10d9a9ddeee8a50cfbbc5665.png)  
in this body the taskid and pocessinstanceid will be passed from last API, variables will be fixed value but with array in it. I tried below and still got a 415.  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/2/5/2528219e18c1476b66d64fed126c4db89d6b9911.png)

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [September 18, 2023, 10:01am UTC](https://community.postman.com/t/how-to-set-a-var-in-a-x-www-form-urlencoded-request-body/51520/5 "2023-09-18T10:01:33Z")

</div>

Pretty sure the body for your request should be raw\JSON, not x-www-form-urlencoded.

---

<div class="post-metadata">

**Author:** ![wangjing0125](https://avatars.discourse-cdn.com/v4/letter/w/e0b2c6/32.png) [@wangjing0125](https://community.postman.com/u/wangjing0125)\
**Post date:** [September 18, 2023, 10:15am UTC](https://community.postman.com/t/how-to-set-a-var-in-a-x-www-form-urlencoded-request-body/51520/6 "2023-09-18T10:15:20Z")

</div>

how should I do parameterization in a raw/JSON ? the other 2 parameters needs to be dynamic

---

<div class="post-metadata">

**Author:** ![wangjing0125](https://avatars.discourse-cdn.com/v4/letter/w/e0b2c6/32.png) [@wangjing0125](https://community.postman.com/u/wangjing0125)\
**Post date:** [September 19, 2023, 8:13am UTC](https://community.postman.com/t/how-to-set-a-var-in-a-x-www-form-urlencoded-request-body/51520/7 "2023-09-19T08:13:56Z")

</div>

set global variable and apply it as below, the issue get resolved. thanks

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/2/320c505fbd1fcc2faa674d9a51c00ff0865d3cfa.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 19, 2023, 8:18am UTC](https://community.postman.com/t/how-to-set-a-var-in-a-x-www-form-urlencoded-request-body/51520/8 "2023-09-19T08:18:47Z")

</div>

Closed on September 19, 2023, 8:18am UTC


