Teilweiser Ausfallshare-external
Issue with Downloading Media via API - Works in Postman but Not in C# Code
1

I am encountering an issue with the WhatsApp Business API for downloading media files. The API call works perfectly when executed through Postman, but the same request fails when implemented in C# code.

I successfully generated the imageUrl. after that it did'nt work for me.

    public static async Task<byte[]> DownloadImageAsync(string imageUrl, string accessToken)
    {
        using (var client = new HttpClient())
        {
            if (!string.IsNullOrEmpty(accessToken))
            {
                client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
            }

            HttpResponseMessage response = await client.GetAsync(imageUrl);

            if (response.IsSuccessStatusCode)
            {
                return await response.Content.ReadAsByteArrayAsync();
            }
            else
            {
                throw new Exception("Failed to download image");
            }
        }
    }
Mukesh
Gefragt vor etwa 5 Monaten