Forum Academy Marketplace Showcase Pricing Features

API Connector Data Type XML with one list item treated as text instead of list of texts

I have an API Connector setup to GET sitemaps. The XML data type is great to translate the XML into a usable object in Bubble. However, the sitemaps I am pulling may have one item in the response OR multiple items. If I initialize the API Connector with a response that has multiple items in the response, Bubble treats the response as an Object with a list of items. But if the sitemap my app GET’s only has one item, Bubble does not treat it as an Object with a list with one item, but rather a text, and subsequently the response with one item gets ignored (because it is not a list).

Examples:
API Call - GET https://johnsoncontrols.taleo.net/careersection/sitemap.jss

  • use as Action
  • Data Type XML

The response to the above is:

https://johnsoncontrols.taleo.net/careersection/sitemap.jss?portalCode=10000&lang=en
https://johnsoncontrols.taleo.net/careersection/sitemap.jss?portalCode=10150&lang=en

image

Which Bubble translates “sitemapindex sitemap” as a list of texts.

Examples:
API Call - GET https://invesco.taleo.net/careersection/sitemap.jss

  • use as Action
  • Data Type XML

The response to the above is:

https://invesco.taleo.net/careersection/sitemap.jss?portalCode=11&lang=en

image

Which Bubble translates “sitemapindex sitemap” to a text. So any subsequent logic that would treat the response as a “list of texts” does nothing, because the response is not a list with one item in Bubble, but rather a text.

I would think if I initialize the API Connector with a response that returns a “list of texts” that a response with one item should be treated as a “list of texts” with one item. Any ideas?

You need to manually edit response. You will need to configure a version with two possibilities and in frontend, you will also need to handle both possibilities

I was afraid that was going to be the answer…