6

I have to send array of ids in GET request as paramenter.How can I test it in Postman(google chrome extension for API testing)?

The scenario is I have url, www.something.com/activity/poi_ids

poi_ids should conatain arrays of ids like [316,318]

At api side using express,

app.get('/activity/:poi_ids',function(req,res){
    var poi_ids = req.params.poi_ids;
    .......
    .......
});

I have looked into it but it is only for post request

Community
  • 1
  • 1
xruptronics
  • 2,785
  • 3
  • 12
  • 17

2 Answers2

7

you can send them via query params .. in your http query params assign all values to same variables like

GET activity?pid=12&pid=23&pid=34

and then inside your express get it like

var ids=req.query.pid; //[12,23,34]
Waqas Noor
  • 911
  • 6
  • 12
4

It is unstructured text. If you want to "send an array" then you'll need to design some way to encode it and then write JavaScript to decode it.

For example:

GET /activity/316-318

and

var poi_ids = req.params.poi_ids.split("-");
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335