#d365-developer_code

1 messages ยท Page 1 of 1 (latest)

half cometBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1285520257355612180

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

polar mountain
silk solstice
#

Yes we are using api calls for our compatibility.

#

Will you please help whats wrong in my code.

#

using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);

            using (var content = new MultipartFormDataContent())
            {
                content.Add(new StringContent(purpose), "purpose");

                // Read the file as a stream
                using (var fileStream = System.IO.File.OpenRead(filePath))
                {
                    content.Add(new StreamContent(fileStream), "file", System.IO.Path.GetFileName(filePath));

                    // Make the request to Stripe
                    var response = await client.PostAsync("https://api.stripe.com/v1/files", content);

                    //response.EnsureSuccessStatusCode(); // Throws an exception if the HTTP response status is an error

                    var responseString = await response.Content.ReadAsStringAsync();
                    return responseString;
                }
            }
        }
#

Here is my code.

polar mountain
#

what is the stack trace, where does "Unauthorised request url"" come from?

silk solstice
#

In response i am getting that error.

polar mountain
#

response to what?

silk solstice
polar mountain
#

are you sure it's not just an error your frontend is seeing from your own backend route, and not actually from the Stripe API? That's what I think. More context + stacktrace would help.

silk solstice
#

This is what exactly i am getting.

polar mountain
#

interesting

#

can you use stripe-dotnet instead? My guess is this is because you're not doing the multipart/form-data correctly

#

actually it's because you have the wrong URL

silk solstice
#

Yes that is why i shared my code.

#

I hope that should work.

silk solstice
#

Oh Okay let me try. thanks.

half cometBOT
grizzled sigil
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!