This sounds basic but I have no clue what postman is doing; my setup is as follows:
input file:
[
{
"url": "http://localhost:3000/gadgets/",
"gadget_id": "8f338a25-c52a-4c47-9d5f-69a6c48c24f2",
"user_id": ""
},
{
"url": "http://localhost:3000/gadgets/",
"gadget_id": "32461687-530e-4730-86c4-00fa4c284cd9",
"user_id": ""
},
{
"url": "http://localhost:3000/gadgets/",
"gadget_id": "913ab956-b89d-41a2-9c09-0a970e202440",
"user_id": ""
},
{
"url": "http://localhost:3000/gadgets/",
"gadget_id": "55c30784-3ad1-4a4e-a781-51a6f0f2fa42",
"user_id": ""
},
{
"url": "http://localhost:3000/gadgets/",
"gadget_id": "55c30784-3ad1-4a4e-a781-51a6f0f2fa42",
"user_id": ""
},
{
"url": "http://localhost:3000/gadgets/",
"gadget_id": "",
"user_id": "4b1c6bc3-d44d-492b-8360-d5076913578b"
},
{
"url": "http://localhost:3000/users/",
"gadget_id": "",
"user_id": "db0722e7-3224-4db1-8a94-372ab462ae70"
},
{
"url": "http://localhost:3000/users/",
"gadget_id": "",
"user_id": "8d0f87f1-6697-4e08-8ddd-0e34e2015787"
},
{
"url": "http://localhost:3000/users/",
"gadget_id": "",
"user_id": "9d788283-87a9-4c38-8d48-30ddc1604058"
},
{
"url": "http://localhost:3000/users/",
"gadget_id": "",
"user_id": "8a86b353-df4c-40fd-a5a1-cfa5f27c41c4"
},
{
"url": "http://localhost:3000/users/",
"gadget_id": "",
"user_id": "a67485e5-fb13-4863-ab55-01fd58c2600f"
},
{
"url": "http://localhost:3000/users/",
"gadget_id": "",
"user_id": "3ab7211d-99e7-4cc6-a862-ac106c2a24de"
},
{
"url": "http://localhost:3000/users/",
"gadget_id": "",
"user_id": "378b2e77-7e18-4d75-b780-c9281b86c8ee"
},
{
"url": "http://localhost:3000/users/",
"gadget_id": "",
"user_id": "df1e35ca-37c5-4026-aa59-ebc02e348fdf"
},
{
"url": "http://localhost:3000/users/",
"gadget_id": "",
"user_id": "2e0aadab-efe2-42e5-9088-c0bb1c6c9631"
}
]
and a POST request in order to create gadgets:
body (raw/JSON):
{
"id": {{gadget_id}}
}
Pre-request script:
// Initialize ids
var gadget_id= pm.iterationData.get("gadget_id");
According to:
https://blog.postman.com/using-variables-inside-postman-and-collection-runner/
this should be enough. The body is not created (id is set empty).
How can I make postman read the file and assign a value to the variable correctly?
Edit:
Tried wrapping the variable into double quotes but it's still not set:
{
"id": "{{gadget_id}}"
}