Fetching XML file from API

Hello all!

I’m trying to fetch an XML file from an API endpoint using context.fetcher.fetch. However, I’m learning the following from the documentation:

if the response headers are text/xml or application/xml, this will be a parsed JavaScript object using the xml2js library. If implicit parsing is undesirable, you may consider using {FetchRequest.isBinaryResponse} on the request to disable any parsing.

That all makes sense ^, however I set isBinaryResponse: true, and the response is still an Object and not the NodeJs Buffer.

Is this intended behaviour?

Any insights are highly appreciated!
Jorge

Hi @Jorge_Conde - Welcome to the Coda Community! Thanks for raising this issue. I’ve just tested it as well and it does appear that we have a bug when using isBinaryResponse: true with XML content. Given that our reference docs specifically call this out as a supported use case I think it’s very likely unintended, and I’ve raised it with our engineering team.

I’m not sure how long it will take to get the bug fixed, so you may want to look for a workaround in the meantime. If you are building your Pack using the CLI then you can include the xml2js library and use it to convert the JSON back to XML again.

Hi @Eric_Koleda - Thank you for testing it on your end!

Agreed, xml2js should be a good workaround for now.