by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Petter Vegsund Brodin
@g2petter
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)))
                    {
                        file.BaseStream.CopyTo(s);
                    }
                },
                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
@g2petter
@alexeyzimarev , didn't know I'd find you here! :)
Alexey Zimarev
@alexeyzimarev
Haha
You can’t escape
You know that you can use an overload of AddFile that accepts the stream reading delegate?
Petter Vegsund Brodin
@g2petter
I realized when looking into it after I posted it, so I'll be doing that now
Alexey Zimarev
@alexeyzimarev
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
@g2petter
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.
pornstache321
@pornstache321
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
thorthumb00
@thorthumb00
Hi all. Can anyone recommend a restsharp code example that implements a search function?
Daan De Lombaert
@DaanDL
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
kikootwo
@kikootwo
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
@35359595
@kikootwo is [JsonIgnore] attribute on target property is sufficient for you?
kikootwo
@kikootwo
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!
kikootwo
@kikootwo
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?
richwaring
@richwaring
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
@santo2
Hi guys, for the RestClient, should that be used as a singleton in your application lifetime?
Stf Kolev
@stfkolev
Greetings, is the docs in the website all that is available to its' current version?
Andrew Ovchinnikov
@andreyIM_twitter
Hi guys. I've noticed that in NuGet RestSharp version 106.6.9.0 has a strong name 106.6.9.0 and starting 106.8.0 it has StrongName version 106.0.0.0. Should it be a bug? This is causing issues with RestSharp being referenced as subdependency by other libraries.
Donovan Edye
@natiki
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?
AtlantisDe
@AtlantisDe
help me ,pls. I Need the RestSharp Post Demo restsharp/RestSharp#1431 thanks
Alexey Zimarev
@alexeyzimarev
@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.
aramacciotti
@aramacciotti
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
@michaelvdnet
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
@MelonCoffeeStudios
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
@driekus77
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
maitevgithub
@maitevgithub
Hi, I successfully generated an access token with RESTSharp. Now I'd like to call an API with that token. How to proceed?
alexkhaos
@ajv_jose_twitter
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
alexkhaos
@ajv_jose_twitter
also how can i get this
RestSharp.Serializers.SimpleJson
cus is request to install the lastest version of the restsharp
Sedat Kapanoglu
@ssg
Hi Folks, the async example on the official page just doesn't compile with the latest version: it says there is no such overload: https://restsharp.dev/getting-started/#asynchronous-calls
Sedat Kapanoglu
@ssg
Nevermind, it was a problem with a stale reference to the older version (.1 instead of .11). :)
advapiIT
@advapiIT
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?
DavidHawkes
@db300
ExecuteAsync don't support callback?
Obsolete?
DeveloperM0303
@DeveloperM0303
Hi Folks, I am using RestSharp version 106.11.4.0. 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!