#d365-developer_code
1 messages ยท Page 1 of 1 (latest)
๐ 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.
hi! any reason you're doing this instead of using stripe-dotnet? https://github.com/stripe/stripe-dotnet/?tab=readme-ov-file#stripenet
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.
what is the stack trace, where does "Unauthorised request url"" come from?
In response i am getting that error.
response to what?
{
"error": {
"message": "Unrecognized request URL (POST: /v1/files). Please see https://stripe.com/docs or we can help at https://support.stripe.com/.",
"type": "invalid_request_error"
}
}
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.
This is what exactly i am getting.
{
"error": {
"message": "Unrecognized request URL (POST: /v1/files). Please see https://stripe.com/docs or we can help at https://support.stripe.com/.",
"type": "invalid_request_error"
}
}
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
Oh Okay let me try. thanks.
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!