restsharp

How do I make a case request from the Pacer.gov API?

大兔子大兔子 提交于 2019-12-04 17:07:34
I am trying to make a request to an API called Pacer.gov. I'm expecting a file to be returned, but I'm not getting it. Can someone help me with what I'm missing? So my C# Rest call looks like this: (The variable PacerSession is the authentication cookie I got (with help from @jonathon-reinhart); read more about that here: How do I use RestSharp to POST a login and password to an API? ) var client = new RestClient("https://pcl.uscourts.gov/dquery"); client.CookieContainer = new System.Net.CookieContainer(); //var request = new RestRequest("/dquery", Method.POST); var request = new RestRequest

Is it possible to use the signed RestSharp NuGet package with Twilio?

守給你的承諾、 提交于 2019-12-04 14:29:49
We're using both DocuSign's API which requires the signed version of RestSharp, and we're looking to integrate Twilio which requires the unsigned version. I've spent a bit of time trying to get both DLLs to resolve for each of their dependencies, and haven't had any luck. At this point, I'm hoping there's a way to use the signed RestSharp dll with Twilio. Has anyone had any experience with this before? When I attempt to remove the unsigned RestSharp, my DocuSign code works fine, but now TwilioRestClient is unable to resolve the dependencies. Both libraries are 105.2.3.0. An exception of type

Restsharp: Deserialize json object with less/more fields than some class

蹲街弑〆低调 提交于 2019-12-04 13:48:24
I'm using Restsharp to deserialize some webservice responses, however, the problem is that sometimes this webservices sends back a json response with a few more fields. I've manage to come around this so far by adding all possible field to my matching model, but this web service will keep adding/removing fields from its response. Eg: Json response that works: { "name": "Daniel", "age": 25 } Matching model: public class Person { public string name { get; set; } public int age { get; set; } } This works fine: Person person = deserializer.Deserialize<Person>(response); Now suppose the json

restsharp - no cookie in response object

混江龙づ霸主 提交于 2019-12-04 11:54:05
I have an issue with one of my requests to localhost server. To authenticate, I need two cookies, one from sendReqForToken() method and one from sendLoginReq(string login, string pass). In response I get cookie from sendLoginReq, but not from sendReqForToken(). I don't have idea why one request has a cookie second doesn't. It is interesting that I get correct token(response content is correct) from sendReqForToken() method, but without any cookie in response header. This is sendReqForToken() method body: public void sendReqForToken() { string adres = Globals.TOKEN_URL; RestRequest request =

Example of RestSharp ASYNC client.ExecuteAsync<T> () works

半世苍凉 提交于 2019-12-04 09:00:34
问题 Could someone please help me modify the code below: client.ExecuteAsync(request, response => { Console.WriteLine(response.Content); }); Basically I want to use ExecuteAsync method above but don't want to print but return response.Content to the caller. Is there any easy way to achieve this? I tried this but doesnt' work: public T Execute<T>(RestRequest request) where T : new() { var client = new RestClient(); client.BaseUrl = BaseUrl; client.Authenticator = new HttpBasicAuthenticator(

Mvc4 RTM validation throwing an error

旧巷老猫 提交于 2019-12-04 07:28:16
Has something changed with the rtm bits regarding the validation of models. I have a simple viewmodel that looks like public class ProductViewModel { [Required] [DataMember(IsRequired = true)] public int ProductTypeId { get; set; } public string Product { get; set; } } (I just added the DataMember(IsRequired = true) as the error message I get says to use it to fix the problem. However no joy) Within my controller the model state is telling me model is valid however when I try passing the model to my api using RestSharp I get the following error. {"Message":"An error has occurred.",

Building XML request with RestSharp

≯℡__Kan透↙ 提交于 2019-12-04 06:53:19
I am attempting to work with a REST API using RestSharp and C#. The documentation for the API that I am using gives a sample XML request: <?xml version='1.0' encoding='UTF-8'?> <messages> <accountreference>EX0000000</accountreference> <from>07700900654</from> <message> <to>07700900123</to> <type>SMS</type> <body>Hello Mr Sands.</body> </message> <message> <to>07700900124</to> <type>SMS</type> <body>Hello Mr Mayo.</body> </message> </messages> I am struggling to understand how to build the request in the format that they want (multiple elements called "message") I have created these classes for

How to make restsharp to work with the right encoding for response?

喜欢而已 提交于 2019-12-04 06:22:34
问题 I have the same problem like this question RestSharp ignores response charset encoding. But there is no right answer! Code like this IRestResponse RSP = client.Execute(request); not like this Encoding encoding = Encoding.GetEncoding("ISO-8859-1"); var result = encoding.GetString(response.RawBytes); It means the resetsharp must deserializ the result with right encoding. Someone can help? 回答1: I solved this problem by myshelf you just down the code source from github and edit the code stemp 1:

Converting HttpClient to RestSharp

天涯浪子 提交于 2019-12-04 05:28:03
I have Httpclient functions that I am trying to convert to RestSharp but I am facing a problem I can't solve with using google. client.BaseAddress = new Uri("http://place.holder.nl/"); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",access_token); HttpResponseMessage response = await client.GetAsync("api/personeel/myID"); string resultJson = response.Content.ReadAsStringAsync().Result; This Code is in my HttpClient code, which works good, but I can't get it to work in RestSharp, I always get Unauthorized when using RestSharp like this: RestClient client =

Twilio RestSharp Dependency

你说的曾经没有我的故事 提交于 2019-12-04 05:17:35
I have just updated a MVC web application running on the ASP.NET Framework version 4.5.2. I am using Twilio to send an SMS message: var twilio = new TwilioRestClient(twilioSid, twilioAuthToken); var result = twilio.SendSmsMessage(twilioNumber, message.Destination, message.Body); After the update, I am getting the following error: System.TypeLoadException: Could not load type 'RestSharp.HttpBasicAuthenticator' from assembly 'RestSharp, Version=105.2.1.0, Culture=neutral, PublicKeyToken=null'. The installed versions are: Twilio 4.0.4 RestSharp 105.2.1 I have seen a similar question posted back