RestAPI Array Params Not Working

  1. My goal: Use Appwrite API in Retool
  2. Issue: I am trying to use the appwrite storage API in the retool which accepts the array of object as params, and retool is not letting me add multiple same name params As i have loaded the openapi spec, and when passing array ob obecjts API is not accepting it.
  3. Steps I've taken to troubleshoot: I have tried to add multiple params but retool is not letting me do that,
  4. Additional info: (Retool Cloud)
[{"method":"limit","values":[{{ table3.pagination.pageSize }}]},{"method":"offset","values":[{{ table3.pagination.offset }}]},{"method":"orderDesc","attribute":""}]

Hi @irfanullah - I’m not certain on this, but you could try stringifying each item in the array like one of these options:

{{ JSON.stringify([ {method:"limit",values:[table3.pagination.pageSize]}, {method:"offset",values:[table3.pagination.offset]}, { method:"orderDesc",attribute:""} ]) }}

  • Sends a single “queries” parameter

{{ [ JSON.stringify({method:"limit",values:[table3.pagination.pageSize]}),JSON.stringify({method:"offset",values:[table3.pagination.offset]}),JSON.stringify({ method:"orderDesc",attribute:""}) ] }}

  • Sends multiple "queries" parameters, each containing a URL encoded object.

One of these might work, good luck!

Thanks

@Jon_Steele Thanks for the reply, I’ve tried both options, but neither worked. The issue happens when we use the OpenAPI spec for an API, it doesn’t allow us to specify that.

However, if I don’t use the OpenAPI spec, I’m able to pass array parameters like the one below, and it works.

Hi @irfanullah Sorry for suggesting something that didn’t work! :slight_smile: I dug into this a bit more and I think I figured out what's going on.

The problem is with Appwrite's OpenAPI spec. Appwrite's server only accepts the queries when they're sent as queries[] (with the empty square brackets repeated). But the OpenAPI spec just describes queries as a plain array of strings and doesn't say anything about needing those brackets.

So when Retool imports that spec, it doesn't know about the bracket requirement and sends the array as queries[0]=...&queries[1]=... instead. I actually tested this and confirmed it and there's no way to change that format when you're using the OpenAPI-based resource. Retool might be doing this wrong as well though because the default for an array should be “style: form, explode: true” - which would mean you send it like this: queries=…&queries=… (without the numbered index) - so actually Retool might be doing this wrong also.

{
"name": "queries",
"in": "query",
"required": false,
"description": "Array of query strings generated using the Query class provided by the SDK. ... Maximum of 100
queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType,
sizeOriginal, chunksTotal, chunksUploaded",
"schema": {
"type": "array",
"items": { "type": "string" },
"default": []
}
}

I think you are going to have to use your workaround - the problem lies in the AppWrite OpenAPI spec - it needs the brackets for it to work with Retool.

Thanks

No worries @Jon_Steele I think I shouldn’t use the OpenAPI spec for now and should stick to regular URLs. Thanks for checking in.

1 Like