In my project I need to test a GET request with Postman with an array of IDs in the URL:
{{ws}}{{url}}/v1/devices/["{{test_devices}}"]/preview/
In the pre-request script I set the value of test_devices:
pm.environment.set("test_devices",['4d9a0f69-1de2-40e3-a907-03de4fedf0ec', '392bf056-99d8-4a2f-ba1a-246c1f01394c']);
But I the syntax seems to be off as I get this error:
ValidationError at /v1/devices/["4d9a0f69-1de2-40e3-a907-03de4fedf0ec,392bf056-99d8-4a2f-ba1a-246c1f01394c"]/preview/
['\'["4d9a0f69-1de2-40e3-a907-03de4fedf0ec,392bf056-99d8-4a2f-ba1a-246c1f01394c"]\' is not a valid UUID.']
I've tried several variations, but all with similar issues. What is the correct syntax?
asked Mar 8, 2019 at 11:23
1 Answer 1
You need to stringify and set the array.
- Update your request URL like so:
{{ws}}{{url}}/v1/devices/{{test_devices}}/preview/
- Update your test script to do a JSON.stringify on the array, like so:
pm.environment.set("test_devices",JSON.stringify(['4d9a0f69-1de2-40e3-a907-03de4fedf0ec', '392bf056-99d8-4a2f-ba1a-246c1f01394c']));
answered Mar 8, 2019 at 11:46