messagebird / csharp-rest-api

This repository contains the open source C# client for MessageBird's REST API.
ISC License
54 stars 60 forks source link

Sending File in WhatsApp Sandbox #80

Closed ahmetkocadogan closed 4 years ago

ahmetkocadogan commented 4 years ago

I am sending a pdf file in whatsapp sandbox, but file is not received. And i got no error or exception while sending.

Is it a bug? Or whatsapp sandbox does not allow sending files?

Sending image and location is working.

dandronic commented 4 years ago

Sending a message via the WA sandbox works correctly (I tested via direct API call):

curl -X "POST" "https://conversations.messagebird.com/v1/send" \
-H "Authorization: AccessKey dummy" \
-H "Content-Type: application/json" \
--data '{ "to":"dummy", "from":"dummy", "type": "file","content": { "file": {"url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"} } }'

and I correctly got the pdf file on client

ahmetkocadogan commented 4 years ago

I am using the C# SDK.

Let me try again, i'll post the result

ahmetkocadogan commented 4 years ago

@dandronic This is what i get from ngrok inspect. And i didn't receive the file. I deleted some parts.

{
    "contact": {
        "id": "",
        "href": "",
        "msisdn": ,
        "displayName": "",
        "firstName": "",
        "lastName": "",
        "customDetails": {},
        "attributes": {},
        "createdDatetime": "2020-08-05T07:43:19Z",
        "updatedDatetime": "2020-08-05T07:43:19Z"
    },
    "conversation": {
        "id": "",
        "contactId": "",
        "status": "active",
        "createdDatetime": "2020-08-05T07:43:19Z",
        "updatedDatetime": "2020-08-21T13:00:11.225311675Z",
        "lastReceivedDatetime": "2020-08-21T13:00:13.189402996Z",
        "lastUsedChannelId": "",
        "messages": {
            "totalCount": 0,
            "href": "https://whatsapp-sandbox.messagebird.com/v1/conversations/xx/messages"
        }
    },
    "message": {
        "id": "",
        "conversationId": "",
        "platform": "whatsapp",
        "to": "+",
        "from": "+",
        "channelId": "",
        "type": "file",
        "content": {
            "file": {
                "url": "https://qconlondon.com/london-2017/system/files/presentation-slides/microsoft_bot_framework_best_practices.pdf"
            }
        },
        "direction": "sent",
        "status": "pending",
        "createdDatetime": "2020-08-21T13:00:13Z",
        "updatedDatetime": "2020-08-21T13:00:13.197911723Z"
    },
    "type": "message.created"
}
dandronic commented 4 years ago

I think there is a problem with that specific pdf (or type). If I send another one (https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf) it works correctly, but the one you are sending it indeed does not get through). I'll research to see if there are any known restrictions/issues with pdf files. Can you do a test with sending https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf ?

dandronic commented 4 years ago

The file you are trying to send https://qconlondon.com/london-2017/system/files/presentation-slides/microsoft_bot_framework_best_practices.pdf is returning a data gzip compressed file/stream. This is something that MessageBird does not currently support (it will be added in the next weeks/months). That's why it is failing. Host the file on a non gzip server and you should not have any more problems.

ahmetkocadogan commented 4 years ago

Thanks. I'll try your pdf file, and close the issue if it succeeds.

ahmetkocadogan commented 4 years ago

@dandronic i sent the pdf file successfully. Thanks for clear explanation. I'am closing the issue.