facebookfacebook-messenger

Facebook Messenger API: "Failed to fetch the file from the url" when the file exists


I am currently attempting to send a hosted image as an attachment using the Facebook Messenger Send API. I make a POST request like the following:

{"message": {"attachment": {"payload": {"url": "http://url.com/image"},
                            "type": "image"}},
 "recipient": {"id": 129760000000000}}

When I access the given URL using a browser, it displays the image. However, the API always returns an error:

{'error': {'code': 100,
           'type': 'OAuthException',
           'fbtrace_id': 'GlCkjxuGMw0',
           'error_subcode': 2018008,
           'message': '(#100) Failed to fetch the file from the url'}}

How can I fix this error? Any help is very appreciated!


Solution

  • For people who may stumble on this question later, I managed to work out the source of the issue. There is an inbuilt file limit for Messenger attachments, and this image (2MB) was over it. Retrying with a smaller image was successful. However, the Messenger documentation unfortunately does not specify the limit, so it's down to guesswork!