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...
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)
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
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)
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.
Yes, file is created - tried to open the jpeg file created, doesn't work
rename it to text file, check it's content -> It's actually HTML doc content
Converted into HTML file and this is what presented.
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.
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.
After weeks of frustration, finally it has come to an end! Thanks all for the help especially @TIMAI2 for personally review the AIA file and tried different method.