Download binary media files from Meta API

Ok, so our API calls are exactly the same (a few header differences, but I’ve tried them all at this point and they don’t seem to matter), but I’m still not able to save the returned binary file in a way that will actually work. I’m lost at this point and not really sure what else to try - any ideas?

So, just to repeat what I’m doing and to make sure that I’m not missing something stupid - here’s the workflow I have going on:

  1. Request the WhatsApp Media API with the media id, which returns the URL for the media download. I’ve confirmed that both of these are returned correctly, so there’s nothing to change here.
  2. Request the WhatsApp Media Download API that you included above, with only the URL that’s returned from the previous API. I’ve confirmed that the URLs work in Postman, which returns an binary / Base64 string that’s able to be opened in the browser with no issues. But, when it’s returned with the Bubble API, even when I initialize it in the API Connector, the file isn’t playable and from what I can tell, isn’t an actual media file at all, but a saved version of a URL that is being sent over for some reason.
  3. I’ve attempted at saving the returned file both with base64 conversion and without and with about any other possible way that I can think of, but everything that I save ends up being a file that doesn’t work.

I guess the biggest issue here (and the issue that started this thread) is that the API response that’s saved to the file manager via the Bubble file upload API isn’t saving as the actual audio file, but some other type of file that Bubble isn’t liking. But, this seems to working fine for you @zapclassbr but I just have no idea why and what I’m doing wrong.

If you want to dive into my account, I’m happy to give you access - I just don’t know what else to try at this point. Thanks again for the help and I still have some hope of getting this to work. Not much, but I still have a little. :slight_smile:

Ok, so I have to give a HUUUUGE shout-out to @redvivi for hooking me up with two amazing plugins that help convert the media files that are being returned as binary from the Meta API. I’ll let him post more about the plugins if he wants, but they helped me figure this out, which also means that it has saved my sanity (for now). He seems to be a bit of a plugin guru, which I think is good to have around here. :pray:

@zapclassbr has also been a really big help and we’ve gone back and forth a bunch about this as well, so I really want to thank him as well as I really, really appreciate it.

So, with that being said, here’s to an amazing weekend, everyone! I know that I’ll be putting a few beers back for all of the help of @zapclassbr and @redvivi and here’s to the next problem that we run into (it probably won’t take too long). :beers:

3 Likes