AI2 HTTP Get request response different from POSTMAN

Hi, I am trying to download an image by submitting a GET request to an URL. The process is as follow:

  1. Retrieve Media URL using Media ID (must include Bearer TOKEN)
  2. Once received Media URL, retrieve the media file by submitting a GET request with bearer TOKEN in header

The steps above follow this -> Media - Cloud API - Documentation - Meta for Developers

When I perform the process above using POSTMAN, it works where the image will be downloaded and displayed (in POSTMAN)

However, when I use AI2 to perform the same action, I get 404 error. Based on research, most likely media URL is expired, or TOKEN is expired. However, when I use the same URL and token in both POSTMAN and AI2 (within the span of say 1 min), POSTMAN gives status 200 response while AI2 gives 404 response which doesn't make sense.

Here's my code. Appreciate your thoughts on what can be the problem.

If you are downloading a file, you need to use the "saveResponse" property and GotFile event.

Thanks for the suggestion. Tried tick "saveResponse", and use GotFile event. The responds code still 404 unfortunately.

What kind of media file is it?
From the documentation

If media fails to download, you will receive a 404 Not Found response code. In that case, we recommend you try to retrieve a new media URL and download it again. If doing so doesn't resolve the issue, please try to renew the ACCESS_TOKEN then retry downloading the media.

Please provide an updated screenshot of your relevant blocks...

In which event do you get it?
Try to set SaveResponse to true in the Blocks...


mime_type = image/jpeg

I renewed the access token following the documentation but it is still give me 404. The strangest thing is, with the same access token, it works in POSTMAN (response code = 200)

Updated the code

Are you happy with your urls in the app. You do not show the structure of your "jsonObject"?

Also, you still need to set saveresponse = true, and responsefilename = myfile.jpg

This is the structure of the jsonObject
"messaging_product": "whatsapp",
"url": "URL",
"mime_type": "MIME_TYPE",
"sha256": "HASH",
"file_size": "FILE_SIZE",
"id": "MEDIA_ID"

Yes, I am happy with the URL retrieved. It is a valid URL (tested and it works using POSTMAN)

I have updated the code to this, but the result is the same. I don't mind to send the AIA file in private in case it will be better. I was trying to see if there's any other HTTP extension to try out but seems like non that I can find. Do correct me if I am wrong.

Just want to make sure that the get Media ID request is returning the data correctly, and that the blocks are extracting the url correctly for the Media URL call.

You are welcome to PM the aia for testing ( I do not have a Facebook account so am completely unconnected there....)

Which Android version are you using for your tests?
What does the parameter filename of the Web GotFile event return?
Was a file created? You might have to use a good file manager like Toral Commander to see that file in ASD...
In case the file is there, rename it to a text file and check its content


I tried the app in Android 12, and Android 7

According to documentation from Facebook, this is what I should expect, binary data of media.

This is what I am expecting my app to do:

  1. Retrieve Media URL by sending Media ID to Facebook end point. (This is successful and confirmed the URL received is working. This also proved the Media ID, the bearer token is valid)
  2. Retrieve binary data of media by sending GET request with Media URL and bearer token. I was using GotText event initially because I was expecting hex values to be returned which then need to do some conversion into the appropriate file format. However, before I can even get any text returned, the responses given by server is 404 which Facebook documentation said either Token or Media URL expired.

Next, I tried GotFile with set SaveResponse = true and set Responsefilename to image.jpeg, but result still return 404.

I continue to investigate by trying different tools (instead of AI2) such as POSTMAN and windows Curl tool. Both provide successful result (POSTMAN automatically convert the binary format into image while Curl convert the binary into file). Please take note that I am expecting a jpeg image.

My thinking is that the steps I did in the tools other than AI2 seem to be working, without getting 404 response. I validated the URL and Access Token by using different tool to test (same Media URL and same Access Token used in AI2), it returned response 200 instead of 404, which means both URL and Token have no problem.

There is an extension Terminal, which have a function Curl. you may want to try that.

You forgot to answer


  1. I set to image.jpeg.
  2. Yes, file is created - tried to open the jpeg file created, doesn't work
  3. rename it to text file, check it's content -> It's actually HTML doc content
  4. Converted into HTML file and this is what presented.
  5. Although this not the final file I am looking for (an image of a taco), but it is the correct file which match with the status 404 returned, telling me that they cannot find the file I am requesting.

Yes, in case of an error as you have seen now you can find the error message hidden in the downloaded file


I have offered to look at your aia project. You can private message it.

Sent. Thank you very much for the help.

Hi all,

I just found this from facebook developer community

Facebook does not accept downloads from official browsers or even if you have not been identified. Try using the http header "User-Agent" with its own ID in all calls

This might be the reason that the call was unsuccessful. Do you have any experience in using User-Agent on android devices? Still exploring how to build that Android string to be included in the header.

I am using this as a reference: How to Correctly Form User-Agents for Mobile Apps | ScientiaMobile.

Trying out... hopefully there's some good news.

If we can run the download command in a webviewer, it is possible to modify the useragent.

I have been having a look with javascript fetch, but coming up against cross origin cors problems while testing on my computer....

Fixed the cors issue, but getting error on response code :frowning: