Rest query parameters in array form?

rita_m
Tera Guru

Hi -

 

We've had a custom pagerduty integration now for many years, and we need to keep using it because we've made one with different features than what the one in the app store offers.

 

With Pagerduty's new upgrade from REST API V1 to V2, we can no longer send a query parameter in comma separated format.  Instead, they want it in an ARRAY!

 

How can I set up an HTTP Query Parameter as an array?

 

doing

fieldname[]

in the parameter name field doesn't work. 

 

I've tried

fieldname

and then

[${value}]

but no luck with that, either.

 

Any ideas?

 

Thanks!

8 REPLIES 8

David Ramirez
Kilo Guru

Based on this Article on PagerDuty: https://v2.developer.pagerduty.com/v2/docs/migrating-to-api-v2

 

To migrate your filters from REST v1 to v2 API:

Filtering
For endpoints that allow filtering by resource ids, the parameter will only accept an array of ids and the name will be the singular form of the resource to filter on followed by _ids.

Previously, filters may have been specified as a comma-separated list, e.g.

/api/v1/incidents?service=PAGRDTY,PGRDUTY

In API v2, the parameter will instead look like

/incidents?service_ids[]=PAGRDTY&service_ids[]=PGRDUTY

 

This info and more tips are explained in the link above

Hi -

 

Yes, I had seen that.  And I had been attempting to change the v1 "status" parameter to the new v2 "statuses" parameter that takes an array...  But I can't figure out how to do that in ServiceNow's REST function.

As I said, I've tried setting it to "statuses[]", and to "statuses" with a value of [val1,val2], and I get errors every time.

 

I know WHAT needs to be done.  Unfortunately, I can't seem to get it to work in ServiceNow!

 

Thanks for trying to help, and any other ideas would be much appreciated.

Have you tried: 

status_ids[]=VAL1&status_ids[]=VAL2

  ?

Hi David -

 

The issue is that I can't get it to work with even a single array value.  Even the simpler option below will not work.

statuses[]=val1

 

Thanks.