Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
Petter Vegsund Brodin
The method reads like this:
        public IRestRequest AddFile(string name, string path, string contentType = null)
            var f = new FileInfo(path);
            var fileLength = f.Length;

            return AddFile(new FileParameter
                Name = name,
                FileName = Path.GetFileName(path),
                ContentLength = fileLength,
                Writer = s =>
                    using (var file = new StreamReader(new FileStream(path, FileMode.Open)))
                ContentType = contentType

I wonder if this FileStream constructor actually requires both read and write permissions:

new FileStream(path, FileMode.Open)

I think that in order to only request read access (which I assume should be enough for the purpose of adding a file to a request) you need to call this constructor instead:

new FileStream(path, FileMode.Open, FileAccess.Read)

Petter Vegsund Brodin
@alexeyzimarev , didn't know I'd find you here! :)
Alexey Zimarev
You can’t escape
You know that you can use an overload of AddFile that accepts the stream reading delegate?
Petter Vegsund Brodin
I realized when looking into it after I posted it, so I'll be doing that now
Alexey Zimarev
If you think we ask for too broad permissions for the file, open an issue on github please
Better submit a PR :smile:
Petter Vegsund Brodin
I thought it might be good to check if it's intentional or not. There might be a reason that I'm not seeing for why you'd require write permissions as well.
restsharp seems to clean up urls automatically... how the fuck do i make it not do that. For example, working with a weird api that has a query string like this: 1m3434&1d34534&2m4353 etc. No values, only keys in the query string. Restsharp just gets rid of the keys all together
Hi all. Can anyone recommend a restsharp code example that implements a search function?
Daan De Lombaert
Does anybody know how one can send a "Date" header in a custom format?
I'm having trouble with it because "Date" is a restricted header and it gets overwritten internally
I googled for quite a while but couldn't find an answer. Is there a way to ignore properties for json serialization using default serialization with restsharp?
Ivan Temchenko
@kikootwo is [JsonIgnore] attribute on target property is sufficient for you?
That doesn't appear to be present without newtonsoft. But I just tested and it seems that even if I supply additional properties in the json it isn't carrying over to the service side, so I'm good! Thanks!
Another odd issue, each time I restart my application that is using my API written with restsharp the put/delete/post request that I make takes like 15 seconds, after that they take 200ms until I restart the application again. Any ideas?
Hi guys - does anyone use RestSharp within Dynamics 365 plugins? When I upload the plugin to D365 it doesn't seem to be able to find the RestSharp assembly.
Peter Derwa
Hi guys, for the RestClient, should that be used as a singleton in your application lifetime?
Stf Kolev
Greetings, is the docs in the website all that is available to its' current version?
Andrew Ovchinnikov
Hi guys. I've noticed that in NuGet RestSharp version has a strong name and starting 106.8.0 it has StrongName version Should it be a bug? This is causing issues with RestSharp being referenced as subdependency by other libraries.
Donovan Edye
Hi.... I am looking to log the raw requests and responses of a RestSharp client.... As this is in a third party library and all I have access to is the RestClient is it possible to add an interceptor / handler so that I can get the raw traffic?
help me ,pls. I Need the RestSharp Post Demo restsharp/RestSharp#1431 thanks
Alexey Zimarev
@AtlantisDe such questions get closed even on StackOverflow. we keep GitHub issues for bug reports and feature requests only. You can formulate your question better on SO and I am sure people will help.
@andreyIM_twitter I guess you found the reported issue already. It is not a bug but the change happened in a minor version, it is indeed an issue.
Can RestSharp help in create a WCF to WebAPI router that be agnostic about which is the method and parameters received but use them to call the REST endpoint, receive the response and then again route it to the original consumer as a WCF response?
Michael van der Net
Hi, I'm implementing a OAuth1 consumer (twitter), and would like to know if it's possible to change the authenticator per request, so I don't have to make a new client for every request and suffer from socket exhaustion?
Aaron Griffin
Hey all, anyone know when RestSharp 107 is coming out?
Or if it is out
I cannae find it
But it seems as tho it's been talked about for years
Henry Roeland
Hi everybody, I should have come hier first:-) I like using RestSharp a lot. But I’m missing 2 things: pluggable and chain able serializers. And hypermedia support like OData and GrapQL. Am I the only one missing these features? Is RestSharp the appropriate lib for these kind of features? Kind regards
Hi, I successfully generated an access token with RESTSharp. Now I'd like to call an API with that token. How to proceed?
hi i have aproblem with restsharp
i was working with an api on visual studio, but with framework 4.7.2 and when i sent it to test, they request to make a downgrade of the framework to 4.5.2 and now im not able to get a response form the api
also how can i get this
cus is request to install the lastest version of the restsharp
Sedat Kapanoglu
Hi Folks, the async example on the official page just doesn't compile with the latest version: it says there is no such overload:
Sedat Kapanoglu
Nevermind, it was a problem with a stale reference to the older version (.1 instead of .11). :)
Hello, I assert that I'm new to restsharp and I need to perform a DeleteCall on a service that accepts Delete action
the problem I've is that if I use it sync it works, here's the code
        public  Task<ResponseItem> PerformShipmentDeleteAsync(ShipmentDeleteRequest objectRequest)
            var client = new RestClient(settingsService.Endpoint);

            var request = new RestRequest("shipment", DataFormat.Json);
            request.AddHeader(Constants.XApiKey, settingsService.ApiXKey);
            request.AddParameter( "text/plain",$"id={objectRequest.Id}", ParameterType.RequestBody);

            var res =  client.Delete(request);

            return res.IsSuccessful ?  Task.Factory.StartNew(() => new ResponseItem { Error = 0}) : Task.Factory.StartNew(() => new ResponseItem { Error = 1, ErrorMessage = res.ErrorMessage});
since the delete does not return anything but have to check on return code, if I use the DeleteAsync, it asks me for a callback
and I've not been able to find how to use it correcly
anyone can show me an example please?
ExecuteAsync don't support callback?
Hi Folks, I am using RestSharp version I am sending file from my C# application to rest api using request.AddFile(name, path). However, I get the response as bad request. Sample code request.AddFile("00003800", @"C:\Temp\test\00003800.pdf". Any help is appreciated.Thanks!