restsharp

Posting GZip content using RestSharp

血红的双手。 提交于 2019-12-09 00:41:01
问题 How do I post GZip data using RestSharp. I have the following code but it isn't working as I would expect: var restRequest = new RestRequest(url, Method.POST) { Timeout = Constants.DefaultTimeoutMilliseconds }; var dataStream = new MemoryStream(); using (var zipStream = new GZipStream(dataStream, CompressionMode.Compress)) { using (var writer = new StreamWriter(zipStream)) { writer.Write(new DotNetXmlSerializer().Serialize(content)); } } var compressedBytes = dataStream.ToArray(); restRequest

Upload to Onedrive with C# using Graph API

依然范特西╮ 提交于 2019-12-08 21:58:24
I am trying to upload a file to Onedrive using RestSharp and Graph API. Basically I want to upload an Excel file. However, even the file saves, there is problem with the content. I am using: https://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/item_uploadcontent using the code: string newToken = "bearer ourtoken"; var client = new RestClient("https://xxx-my.sharepoint.com/_api/v2.0/"+ oneDrivePath + Path.GetFileName(filePathWithName) + ":/content"); var request = new RestRequest(Method.PUT); request.RequestFormat = DataFormat.Json; request.AddHeader("Authorization", newToken); request

Upload to Onedrive with C# using Graph API

蓝咒 提交于 2019-12-08 21:58:22
I am trying to upload a file to Onedrive using RestSharp and Graph API. Basically I want to upload an Excel file. However, even the file saves, there is problem with the content. I am using: https://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/item_uploadcontent using the code: string newToken = "bearer ourtoken"; var client = new RestClient("https://xxx-my.sharepoint.com/_api/v2.0/"+ oneDrivePath + Path.GetFileName(filePathWithName) + ":/content"); var request = new RestRequest(Method.PUT); request.RequestFormat = DataFormat.Json; request.AddHeader("Authorization", newToken); request

Access Etsy API oauth using c# RestSharp

◇◆丶佛笑我妖孽 提交于 2019-12-08 21:25:31
I set up a developer acct under our shop, to access our sales receipts. I decided to use RestSharp to make my requests. I have proved it works for none Oauth required calls. I have successfully received my accessToken and accessTokenSecret. So i use those along with the customerKey and customerSecret to make a ForProtectedResource call, for a oauth request as follows but always receive "This method requires authentication". I'm hoping its something simple I'm missing. I thought, all I need to make any call are those four items correct? Once I have those four items I don't have to request or

How to access the HTTP request body using RestSharp?

只谈情不闲聊 提交于 2019-12-08 14:32:13
问题 I'm building a RESTful API client in C# .NET 3.5. I first started building it with the good old HttpWebClient (and HttpWebResponse ), I could do whatever I wanted with. I were happy. The only thing I was stuck on was the automatic deserialization from JSON response. So, I've heard about a wonderful library called RestSharp (104.1) which eases the development of RESTful API clients, and automatically deserialize JSON and XML responses. I switched all my code on it, but now I realize I can't do

How do I ignore properties when using RestSharp serialization

∥☆過路亽.° 提交于 2019-12-08 11:09:28
问题 I was looking for something like this: ... public string FirstName { get; set; } public string LastName { get; set; } [Ignore] public string FullName { get { return FirstName + " " + LastName; } } ... But, can't seem to dig anything up. Environment: Xamarin Studio, C#, Android Project running on Mac 回答1: This is dependant on which serializer you are using: For the JsonSerializer, use [ScriptIgnore] . For the DotNetXmlSerializer, use [System.Xml.Serialization.XmlIgnore] . I can't answer with

Visual Studio 2013 - NuGet loads Restsharp 105.0 with Twilio library. Twilio is dependent on 104.4

不问归期 提交于 2019-12-08 09:23:09
问题 Is a new Twilio package on the way? I just signed up for your service and I'm getting the exception due to a dependency on RestSharp V104.4. Nuget installs Restsharp v105.0 with the Twilio library. The error occurs when I hit this line: var twilio = new TwilioRestClient(AccountSid, AuthToken); Error is: Could not load file or assembly "RestSharp, Version=104.4.0.0..." 回答1: You can avoid the problem by installing the correct version of RestSharp through Package Manager Console. Make sure you

Rest Sharp Execute<Int> fails due to cast exception

拈花ヽ惹草 提交于 2019-12-08 08:45:20
问题 I have this: public Int32 NumberOfLocationsForCompany(int companyId) { var response = _curl.ResetRequest() .WithPath(LOCATION_URL) .AddParam("companyId", companyId.ToString()) .RequestAsGet() .ProcessRequest<Int32>(); return response; } that calls this at the end. public T ProcessRequest<T>() where T : new() { var response = _client.Execute<T>(_request); if (response.ErrorException != null) { throw response.ErrorException; } return response.Data; } but I get this error. I don't get why it's

Authentication failing with multiple threads c#

偶尔善良 提交于 2019-12-08 08:24:24
问题 I'm currently writing a web application that provides some database manipulation. The system also needs to be capable working with different databases.The problem is that certain fields in the database have to be updated with data from a RESTful api. To perform these updates, I use a Quartz.NET schedule that makes a job for every table that needs to be updated.This job checks if it needs to update the relevant database. If it does, it gets the information from the REST-service. When I don't

Upload to dropbox using Restsharp PCL

你离开我真会死。 提交于 2019-12-08 06:28:18
问题 I am trying to upload a file to Dropbox using PCL using RestSharp.Portable. My code is public async Task<object> UploadFile(Stream fileStream, string fileName) { var client = new RestClient("https://api-content.dropbox.com"); client.ClearEncodings(); client.AddEncoding("gzip", new GzipEncoding()); var request = new RestRequest("1/files/dropbox/Apps/FileBolt", HttpMethod.Post); request.AddHeader("Authorization", string.Format("Bearer {0}", Token)); request.AddParameter("file", fileName); byte[