API Not Recognizing List of Text as Input Parameter When Calling from External App
Options
![Benedict A](https://us.v-cdn.net/6037124/user_avatars/1781498.jpg)
Benedict A
Member ✭
Would appreciate some help identifying how to correctly pass an array of text as an input parameter when making a call from outside Xano. I set up a test API with details below.
This API that accepts a list of text values called "locations".
[image.png]
Then I set up a loop such that for each location in the input list, the API searches a table for records where the "inqLoc" = the current item in the loop, and returns a count.
This is what the location field in the table looks like: it is just a text field
[image.png]
This is a sample payload and sample result when I test within Xano. It all works.
[image.png][image.png]
But when I test the API using Postman or from an external app, it treats the input list as one string of text, instead of individual items. I've entered the input list using the syntax within Xano, and tried other ways as well.
Here's the result when I pass multiple input items via Postman: no luck
[Screen Shot 2021-09-03 at 9.31.15 AM.png]
Here's the result when I pass only one input item using Postman: it works
[Screen Shot 2021-09-03 at 9.33.12 AM.png]I need to make this work--instead of formatting the output using aggregate-- because the final function I'm working on is more complex than a count.
This API that accepts a list of text values called "locations".
[image.png]
Then I set up a loop such that for each location in the input list, the API searches a table for records where the "inqLoc" = the current item in the loop, and returns a count.
This is what the location field in the table looks like: it is just a text field
[image.png]
This is a sample payload and sample result when I test within Xano. It all works.
[image.png][image.png]
But when I test the API using Postman or from an external app, it treats the input list as one string of text, instead of individual items. I've entered the input list using the syntax within Xano, and tried other ways as well.
Here's the result when I pass multiple input items via Postman: no luck
[Screen Shot 2021-09-03 at 9.31.15 AM.png]
Here's the result when I pass only one input item using Postman: it works
[Screen Shot 2021-09-03 at 9.33.12 AM.png]I need to make this work--instead of formatting the output using aggregate-- because the final function I'm working on is more complex than a count.
Comments
-
Hey ,
The issue is you are passing it in as text instead of an array.
The easiest way to do this is by using a POST api request and sending json data. Make sure to set a header of Content-Type: application/json
{
"locations": ["name1","name2"]
}If you still have issues, attach your postman file here and I'll edit it for you. -
if you want to use a GET request, then you need to use the query parameters a bit differently.
This format will work for you - https://x8ki-letl-twmt.n7.xano.io/api:FbjyB138/APPRAISALS?locations[]=Yaletown+Roundhouse&locations[]=Vancouver+Toyota -
Thanks for your help. I believe the issue was that my input type should have been JSON, not a list of text. This enabled the API to interpret the input as an array.
[image.png]
[image.png]
[image.png] -
That only would be when using a GET api request. Passing lists via query params isn't straight forward, which is why it is easier to use a POST api request when doing things like this.
When doing a POST request, you can pass the entire payload as json, so it is much more straight forward.
Glad you found a solution though - very clever.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback