0

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

3

You need to stringify and set the array.

  1. Update your request URL like so:

{{ws}}{{url}}/v1/devices/{{test_devices}}/preview/

  1. 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

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.