restsharp

Do not encode parameters in RestSharp

给你一囗甜甜゛ 提交于 2019-12-19 07:52:31
问题 I am using RestSharp to access a RubyOnRails API. As you might know, RoR likes when the parameters names are in the form model_name[property] . RestSharp, on the other hand, does not like it. Fiddler says I send this to the server : user%5Bemail%5D=user%40email.com&user%5Bpassword%5D=test It looks like R# encodes both the parameters and values when it sends the data (unlike Curl, which looks like it encodes selectively). While that's fine most of the time I guess, in this particular case, it

Getting signature_invalid calling oauth/request_token for Etsy's API using RestSharp

巧了我就是萌 提交于 2019-12-19 03:39:19
问题 I'm trying to use RestSharp to access Etsy's API. Here's the code I'm using attempting to get an OAuth access token: var authenticator = OAuth1Authenticator.ForRequestToken( ConfigurationManager.AppSettings["ApiKey"], ConfigurationManager.AppSettings["ApiSecret"]); // same result with or without this next line: // authenticator.ParameterHandling = OAuthParameterHandling.UrlOrPostParameters; this.Client.Authenticator = authenticator; var request = new RestRequest("oauth/request_token")

Add certificate on request with RestSharp

十年热恋 提交于 2019-12-19 03:03:32
问题 I'm trying to communicate with a server. This server send me a certificate and a private key in order to execute my request successfully. To test the server, I use Postman. So I fill the certificate setting in postman, and my request works fine Now I want to do the same in C#. For that I use RestSharp in order to create the request. Here is my code var client = new RestClient(url); byte[] certBuffer = UtilsService.GetBytesFromPEM(myCertificate, Models.Enum.PemStringType.Certificate); byte[]

RestSharp client returns all properties as null when deserializing JSON response

感情迁移 提交于 2019-12-18 13:04:14
问题 I'm trying to do a very simple example of using RestSharp's Execute method of querying a rest endpoint and serializing to a POCO. However, everything I try results in a response.Data object that has all properties with a NULL value. Here is the JSON response: { "Result": { "Location": { "BusinessUnit": "BTA", "BusinessUnitName": "CASINO", "LocationId": "4070", "LocationCode": "ZBTA", "LocationName": "Name of Casino" } } } Here is my test code [TestMethod] public void TestLocationsGetById() {

How can I convert this .NET RestSharp code to Microsoft.Net.Http HttpClient code?

瘦欲@ 提交于 2019-12-18 12:32:30
问题 I'm trying to figure out how to use HttpClient to POST some simple parameters. Email Password I've been doing this with RestSharp, but I'm trying to migrate off that. How can I do this with HttpClient , please? I have the following RestSharp code var restRequest = new RestRequest("account/authenticate", Method.POST); restRequest.AddParameter("Email", email); restRequest.AddParameter("Password", password); How can I convert that to use the (Microsoft.Net.Http) HttpClient class, instead? Take

How to idiomatically handle HTTP error codes when using RestSharp?

好久不见. 提交于 2019-12-18 11:47:33
问题 I'm building an HTTP API client using RestSharp, and I've noticed that when the server returns an HTTP error code (401 Unauthorized, 404 Not Found, 500 Internal Server Error, etc.) the RestClient.Execute() doesn't throw an exception - instead I get a valid RestResponse with a null .Data property. I don't want to manually check for every possible HTTP error code within my API client - does RestSharp provide a better way of passing these errors to my client application? A little further detail.

RestSharp print raw request and response headers

荒凉一梦 提交于 2019-12-18 10:24:28
问题 I'm using RestSharp to make calls to a webservice. All is well but I was wondering if it would be possible to print the raw request headers and body that is sent out and the raw response headers and the response body that comes back. This is my code where I create a request and get a response back public static TResponse ExecutePostCall<TResponse, TRequest>(String url, TRequest requestData, string token= "") where TResponse : new() { RestRequest request = new RestRequest(url, Method.POST); if

RestSharp Authenticator Follow 302 Redirect

我只是一个虾纸丫 提交于 2019-12-18 05:07:11
问题 I am trying to make requests to an API with RestSharp. This API is secured by redirecting the request to a login server, authenticate with basic credentials, obtain cookies, then redirect back to the API. I am afraid i have no control over the this. So the sequence of requests is: Request Response --------------------------------------------------------------------------------- 1. GET http api server 302 Found to login server 2. GET https login server 401 Unauthorized 3. GET https login

How to use restsharp to download file

China☆狼群 提交于 2019-12-18 03:48:39
问题 I have a URL (URL for the live feed from client) which when I hit in browser returns the xml response . I have saved this in text file it`s size is 8 MB. now my problem is that I need to save this response in xml file on server`s drive. from there I will insert this in database. and request needs to be made using code using http-client or rest-sharp library of c# .net 4.5 I am unsure what should I do for above case. can any body suggest me something 回答1: With RestSharp, it's right there in

RestSharp Post a JSON Object

偶尔善良 提交于 2019-12-18 03:05:11
问题 I am trying to post the following JSON with RestSharp: {"UserName":"UAT1206252627", "SecurityQuestion":{ "Id":"Q03", "Answer":"Business", "Hint":"The answer is Business" }, } I think that I am close, but I seem to be struggling with the SecurityQuestion (the API is throwing an error saying a parameter is missing, but it doesn't say which one) This is the code I have so far: var request = new RestRequest("api/register", Method.POST); request.RequestFormat = DataFormat.Json; request