- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
AddFile() version 107.1.2-alpha.0.7 not working #1715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm also having this issue in version 107.1.1 however its slightly different. |
I commented in another issue where you commented. I am not sure why you are adding the accept encoding header. File uploads work fine. |
AddFile works. You can debug your request using requestbin.com |
@bfcavaco Trace you request, I am sure it's the parameters you add that break it. You only need AddFile. |
Also, it seems like the server returned you a JSON response, but you never posted it in the issue. The server must be telling you what the issue is. |
@bfcavaco Trace you request, I am sure it's the parameters you add that break it. You only need AddFile. I could be that but: |
Again, you got a JSON response from the server, which probably tells you what is wrong, but you don't expose what the server returned you. Also, it is always a good idea (and the issue template suggests that) to make test calls to a call tracer like requestbin.com, both with a working request, and a failing request. That way you can easily compare what is the difference between those. I totally understand your PoV that it used to work, and it doesn't work now. But it is not enough to diagnose the issue. RestSharp v107 doesn't compose requests as the previous version does. It uses content classes derived from |
Hi Alexey,
Here is the API documentation for uploading a file:
[image: image.png]
And here are the setting using Postman:
[image: image.png]
Using postman it works, I'm able to upload the file.
So, there must be a parameter I'm using incorrectly on restSharp.
Best Regards,
Bruno Cavaco.
Alexey Zimarev ***@***.***> escreveu no dia sábado,
22/01/2022 à(s) 14:28:
… Accept-Encoding header is for specifying the encoding accepted by the
client for the response. But you are setting it to a value which is not a
valid encoding, it's a content type.
Again, you got a JSON response from the server, which probably tells you
what is wrong, but you don't expose what the server returned you.
Also, it is always a good idea (and the issue template suggests that) to
make test calls to a call tracer like requestbin.com, both with a working
request, and a failing request. That way you can easily compare what is the
difference between those.
I totally understand your PoV that it used to work, and it doesn't work
now. But it is not enough to diagnose the issue. RestSharp v107 doesn't
compose requests as the previous version does. It uses content classes
derived from HttpContent and adds the content to the HttpRequestMessage,
which is sent to the server by HttpClient. And normally it "just works",
but there are tons of awkward servers that have weird requirements and fail
on legit requests, so without knowing (best) what the server wants or (at
least) being able to compare a working request with failing request, the
issue is impossible to diagnose.
—
Reply to this email directly, view it on GitHub
<#1715 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AI46KT3VWETLVUXPRKZ63QTUXK5I7ANCNFSM5MOCYYUA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
No images, sorry |
I found that people complain about |
The only difference I have seen before is |
Here's the request made with 107.1.2-alpha.0.18 You can see those requests for yourself here https://requestbin.com/r/enp1nn2lipju/248wgSbG7XvRjoAPT7teiswbRUn |
I'm gonna check with the server maintainer what that StatusCode mean. |
Good news, |
Nice. I'm glad that we found the root cause. |
Thanks a lot :) |
Describe the bug
"StatusCode: InternalServerError, Content-Type: application/json, Content-Length: 16)"
To Reproduce
RestClient client = new(strResource);
RestRequest request = new("", Method.Post);
request.AddParameter("Accept-Encoding", "multipart/form-data", ParameterType.HttpHeader);
request.AddParameter("Authorization", CalibryAuthentication.CalibryToken, ParameterType.HttpHeader);
request.AddFile("file", strFile, "application/pdf");
var restResponse = client.ExecuteAsync(request).Result;
Expected behavior
Should return statusCode == "OK"
Stack trace
There is not stack trace for this issue, only the return status:
InternalServerError, Content-Type: application/json, Content-Length: 16)
Desktop (please complete the following information):
Additional context
The bug does not crash the code, only keeps returning the same error.
The text was updated successfully, but these errors were encountered: