How can I send a Rest message request where the same query parameter is used more than once?

mpsteve137
Tera Expert

I need to send a post request where the query parameter "interaction-id" is used multiple times. I've tried using rest.setQueryParameter("interaction-id", "value"), but that just overrides the same value instead of appending it to the request multiple times. any ideas?

3 REPLIES 3

Amit Verma
Kilo Patron
Kilo Patron

Hi @mpsteve137 

 

Do you want to pass multiple values of interaction-id in a POST request ? 

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Ravi Gaurav
Giga Sage
Giga Sage

Hi @mpsteve137 

 

In ServiceNow's RESTMessageV2 API, calling rest.setQueryParameter("key", "value") multiple times for the same key will override the previous value. To include the same query parameter multiple times, you need to append them manually to the endpoint URL instead of using setQueryParameter.

Instead of using setQueryParameter, construct the full URL with all the repeated query parameters.

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

Ankur Bawiskar
Tera Patron
Tera Patron

@mpsteve137 

why are you having 2 query parameters with same name?

it will override with the latest one

Please check with the 3rd party whose API you are consuming and ensure the query parameter is correct and unique.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader