gabrieldwight / Whatsapp-Business-Cloud-Api-Net

This is C# wrapper of whatsapp business cloud api for .NET
MIT License
283 stars 104 forks source link

Error when download media from url #70

Closed pablosanchezuy closed 4 months ago

pablosanchezuy commented 4 months ago

var results = _whatsAppBusinessClient.GetMediaUrl(id); var imageBytes = _whatsAppBusinessClient.DownloadMedia(results.Url); //I have an error on this line

Exception captured System.ArgumentException: 'The value cannot be null or empty. Arg_ParamName_Name' exception

gabrieldwight commented 4 months ago

If it is an old media id, then it was either deleted earlier by WhatsApp or it is passed 30 days on persistence from their end. Remember the media URL from the media id expires after 5 minutes which you will have to retrieve again when expired.

pablosanchezuy commented 4 months ago

Hi Gabriel, how are you? I have used your code but the error always happens The url is new.

[image: image.png]

Thanks Regards

Pablo Sánchez

El mar, 20 feb 2024 a las 17:45, Gabriel Odero @.***>) escribió:

If it is an old media id, then it was either deleted earlier by WhatsApp or it is passed 30 days on persistence from their end. Remember the media URL from the media id expires after 5 minutes which you will have to retrieve again when expired.

— Reply to this email directly, view it on GitHub https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/issues/70#issuecomment-1955051031, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGI3WQXKLCQDJYFK3DYX5ZDYUUDPHAVCNFSM6AAAAABDRJEANWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJVGA2TCMBTGE . You are receiving this because you authored the thread.Message ID: @.*** .com>

gabrieldwight commented 4 months ago

Hi, I will investigate on the error for the media url to see where the issue is coming from. By any chance are you trying to get url from a video media

On Wed, 21 Feb 2024, 15:49 pablosanchezuy, @.***> wrote:

Hi Gabriel, how are you? I have used your code but the error always happens The url is new.

[image: image.png]

Thanks Regards

Pablo Sánchez

El mar, 20 feb 2024 a las 17:45, Gabriel Odero @.***>) escribió:

If it is an old media id, then it was either deleted earlier by WhatsApp or it is passed 30 days on persistence from their end. Remember the media URL from the media id expires after 5 minutes which you will have to retrieve again when expired.

— Reply to this email directly, view it on GitHub < https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/issues/70#issuecomment-1955051031>,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/AGI3WQXKLCQDJYFK3DYX5ZDYUUDPHAVCNFSM6AAAAABDRJEANWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJVGA2TCMBTGE>

. You are receiving this because you authored the thread.Message ID: @.*** .com>

— Reply to this email directly, view it on GitHub https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/issues/70#issuecomment-1956582149, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGWLN726KAZI5OWWQX7XXCLYUXUMFAVCNFSM6AAAAABDRJEANWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJWGU4DEMJUHE . You are receiving this because you commented.Message ID: @.*** .com>

pablosanchezuy commented 4 months ago

Hi, I tring to download the image

[image: image.png]

[image: image.png]

From the whatsapp api direct works fine. You are from Brazil?

Thanks Regards

Pablo Sánchez

El mié, 21 feb 2024 a las 13:26, Gabriel Odero @.***>) escribió:

Hi, I will investigate on the error for the media url to see where the issue is coming from. By any chance are you trying to get url from a video media

On Wed, 21 Feb 2024, 15:49 pablosanchezuy, @.***> wrote:

Hi Gabriel, how are you? I have used your code but the error always happens The url is new.

[image: image.png]

Thanks Regards

Pablo Sánchez

El mar, 20 feb 2024 a las 17:45, Gabriel Odero @.***>) escribió:

If it is an old media id, then it was either deleted earlier by WhatsApp or it is passed 30 days on persistence from their end. Remember the media URL from the media id expires after 5 minutes which you will have to retrieve again when expired.

— Reply to this email directly, view it on GitHub <

https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/issues/70#issuecomment-1955051031>,

or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AGI3WQXKLCQDJYFK3DYX5ZDYUUDPHAVCNFSM6AAAAABDRJEANWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJVGA2TCMBTGE>

. You are receiving this because you authored the thread.Message ID: @.*** .com>

— Reply to this email directly, view it on GitHub < https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/issues/70#issuecomment-1956582149>,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/AGWLN726KAZI5OWWQX7XXCLYUXUMFAVCNFSM6AAAAABDRJEANWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJWGU4DEMJUHE>

. You are receiving this because you commented.Message ID: @.*** .com>

— Reply to this email directly, view it on GitHub https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/issues/70#issuecomment-1957193927, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGI3WQWC3SOUGDQZYP652R3YUYNZTAVCNFSM6AAAAABDRJEANWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJXGE4TGOJSG4 . You are receiving this because you authored the thread.Message ID: @.*** .com>

gabrieldwight commented 4 months ago

@pablosanchezuy I'm not from Brazil. On my side, I'm able to get the media URL after uploading the media as you can see below: image

Please make sure you check the results returned from getmediaurl function returns the file size greater than zero and also check on the content type returned from the function.

using the same URL from the result to download the media without any issue as you can see the mediaBytes length is not zero. image

pablosanchezuy commented 4 months ago

Hello Gabriel, run ok in this line: GetMediaUrlAsync

[image: image.png]

But when execute this method: DownloadMediaAsync I obtain an exception it's very strange

[image: image.png]

Anyway thank you very much Greetings

Pablo Sánchez

El mié, 21 feb 2024 a las 18:10, Gabriel Odero @.***>) escribió:

@pablosanchezuy https://github.com/pablosanchezuy I'm not from Brazil. On my side, I'm able to get the media URL after uploading the media as you can see below: image.png (view on web) https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/assets/28096255/0d36f2e0-0249-4bf8-b023-f0fbc6e43265

Please make sure you check the results returned from getmediaurl function returns the file size greater than zero and also check on the content type returned from the function.

using the same URL from the result to download the media without any issue as you can see the mediaBytes length is not zero. image.png (view on web) https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/assets/28096255/dc91efc4-5cfa-44aa-9ded-c57018db6e42

— Reply to this email directly, view it on GitHub https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/issues/70#issuecomment-1957945997, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGI3WQRPXCD6FN3RJU7L2J3YUZPFFAVCNFSM6AAAAABDRJEANWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJXHE2DKOJZG4 . You are receiving this because you were mentioned.Message ID: @.*** .com>

portisk8 commented 4 months ago

@pablosanchezuy The same error happened to me. And it was because I was not passing these parameters in WhatsAppBusinessCloudApiConfig:

gabrieldwight commented 4 months ago

@pablosanchezuy From version 18 and above of graph API will require to pass the AppName and Version if you want the download media function to work

pablosanchezuy commented 4 months ago

Hi Gabriel, how are you? I was not passing on those attributes to her, that is surely the mistake. I'm going to correct it Thanks you Regards

Pablo Sánchez

El sáb, 2 mar 2024 a las 21:29, Gabriel Odero @.***>) escribió:

@pablosanchezuy https://github.com/pablosanchezuy From version 18 and above of graph API will require to pass the AppName and Version if you want the download media function to work

— Reply to this email directly, view it on GitHub https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/issues/70#issuecomment-1974954399, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGI3WQQBKVQUSH4VKMWNGBDYWJVFVAVCNFSM6AAAAABDRJEANWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZUHE2TIMZZHE . You are receiving this because you were mentioned.Message ID: @.*** .com>

gabrieldwight commented 4 months ago

Hi Pablo, I'm doing fine. You can let me know if the above attributes work on your side.