I'm trying to use Google's Batch API to hit the Gmail API, but having trouble setting this up in the External API function.
I think the core problem is figuring out what I need to set as the params field in Xano (all the Xano docs focus on a file resource, but that's not what I'm dealing with here - its a list of application/http instead)
Xano seems to be handling determining the boundary
field itself (I set the multipart/mixed header and Xano added the boundary field itself). But part of the spec is to add that boundary value as a divider between each application/http element.
I've tried setting params to:
an array of texts, each of which contains the raw application/http data, like ["Content-Type:application/http POST /gmail/v1/users/me/threads/18fc4a9f0614465b","Content-Type: application/http POST /gmail/v1/users/me/threads/18fc4868e82aaa76"]
an array of objects structured like an HTTP request, i.e. [{"Content-Type":"application/http","method":"POST","url":"/gmail/v1/users/me/threads/18fc4a9f0614465b"},{"Content-Type":"application/http","method":"POST","url":"/gmail/v1/users/me/threads/18fc4868e82aaa76"}]
A single text string that joins the array of texts described above into a string
An example API call (using an array of objects) is shown below with the response I'm getting from the Google API. I get the same response in the other params approaches discussed above.
API Doc: https://developers.google.com/gmail/api/guides/batch
{"request":{"url":"https://gmail.googleapis.com/batch/gmail/v1/","method":"POST","headers":["POST /batch/gmail/v1/ HTTP/2","Host: gmail.googleapis.com","Accept-Encoding: gzip, deflate","Authorization: Bearer <redacted key>","Accept: application/json","Content-Length: 20842","Content-Type: multipart/mixed; boundary=------------------------lE9hAKPRBp3ZdjuBwoQq6Y"],"params":[{"Content-Type":"application/http","method":"POST","url":"/gmail/v1/users/me/threads/18fc4a9f0614465b"},{"Content-Type":"application/http","method":"POST","url":"/gmail/v1/users/me/threads/18fc4868e82aaa76"},...<removed from example>]},"response":{"headers":["HTTP/2 400","vary: Origin","vary: X-Origin","vary: Referer","content-type: application/json; charset=UTF-8","content-encoding: gzip","date: Wed, 29 May 2024 14:29:45 GMT","server: ESF","cache-control: private","content-length: 166","x-xss-protection: 0","x-frame-options: SAMEORIGIN","x-content-type-options: nosniff"],"result":{"error":{"code":400,"message":"Failed to parse batch request, error: 0 items. Received batch body: (20747) bytes redacted","status":"INVALID_ARGUMENT"}},"status":400}}
```