Closed nabramow closed 6 months ago
Okay, I've solved this now. Here was the issue:
For the formData, it needs a third argument "filename".
Appending the binary file string to the formData "contents" key should look like this:
formData.append('contents', binaryPdfString, `myPdfName.pdf`);
In your docs it just shows:
formData.append('contents', binaryPdfString);
So you might want to fix that in the docs here: https://developers.telnyx.com/openapi/programmablefax/tag/Programmable-Fax-Commands/#tag/Programmable-Fax-Commands/operation/SendFax
My second issue I think was related to the package we're using to fetch in node, we're using "isomorphic fetch" package.
For some reason it didn't like me manually inserting the "Content-Type" in the headers, I had to spread it from the formData instead like this:
const headers = {
Authorization: `Bearer API_KEY`,
...formData.getHeaders(),
};
I figured that out from this post, in case anyone has the same issue: https://stackoverflow.com/questions/43500514/how-to-post-with-multipart-form-data-header-and-formdata-using-fetch
Gonna leave this open just because you probably want to update the docs?
Also it would be great if there was support for this in Node SDK! Or at least make it clear in the docs it's not possible to send multipart/form-data when using Node SDK as it took me ages to figure out as it still shows it as a possibility in the docs.
Thanks for bringing this up! I'll take a look and get back to you on this. There should be plans to support this at the SDK, I'll try to document the best case approach of sending this kind of media data and not just linking the urls.
This should be resolved with the latest update, will be adding full fledged form support to when TS gets implemented to make it more straightforward in attaching it
Hi @ADandyGuyInSpace is there any example code on how to use this to send the file binary content with the multipart/form-data content-type?
I'm trying to figure out how to send a fax using the
contents
key rather thanmedia_url
. In the docs under send fax it allows me to select "multi-part/form-data" but in the Node SDK bit it still showsmedia-url
.https://developers.telnyx.com/openapi/programmablefax/tag/Programmable-Fax-Commands/#tag/Programmable-Fax-Commands/operation/SendFax
How can I use the contents key to send a fax?
This is what I have:
This is getting me the following error:
error (Status 422) (Request 33035a3d-e6bd-4149-8d52-7fa00210dc83) 'contents' is invalid
.I can't figure out if the docs are wrong or if it's a bug. I also don't see an option to add a multi-part/form-data
Content-Type
header.Any chance y'all have an example?