restsharp

RestSharp: Could not create SSL/TLS secure channel

自古美人都是妖i 提交于 2019-12-12 13:13:50
问题 I'm trying to use RestSharp in Visual Studio 2012 Express on a fresh install of Windows 8.1. The API I'm trying to use supports only RC4-SHA for SSL. The certificate is valid. var client = new RestClient(); client.BaseUrl = "https://teststore.mybigcommerce.com/api/v2/"; client.Authenticator = new HttpBasicAuthenticator("username", "key"); var request = new RestRequest(); request.Resource = "time.json"; IRestResponse response = client.Execute(bcrequest); I keep getting an error from the client

How to deserialize element with attribute

◇◆丶佛笑我妖孽 提交于 2019-12-12 11:34:07
问题 I'm consuming a RESTful web service by using RESTSharp. One of the XML elements looks like the following: <temp_c units="°C">7.9</temp_c> And the C# class POCO is as follows: public class Test { public TempC temp_c { get; set; } } public class TempC { public string units { get; set; } public string value { get; set; } } When I use RESTSharp, I get the TempC object populated with units but not with an actual value; e.g. 7.9. The value is NULL. 回答1: Fixed the problem by changing the property

RESTSharp has problems deserializing XML including Byte Order Mark?

末鹿安然 提交于 2019-12-12 10:39:40
问题 There is a public webservice which I want to use in a short C# Application: http://ws.parlament.ch/ The returned XML from this webservice has a "BOM" at the beginning, which causes RESTSharp to fail the deserializing of the XML with the following error message: Error retrieving response. Check inner details for more info. ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw

How to set the Content-Type header for a RestRequest?

╄→гoц情女王★ 提交于 2019-12-12 10:25:32
问题 I have a web service in a RESTful web server (java) which consumes media of type MULTIPART_FORM_DATA and produces APPLICATION_JSON . I'm working on a REST client (C#) and using this web service. I'm using RestSharp as the REST client. My code goes as follows: RestRequest request = new RestRequest("addDelivery", Method.POST); request.AddParameter("sessionId", this.sessionId); request.AddParameter("deliveryTo", DeliveryTo); request.AddParameter("deliveryName", DeliveryName); if (fileList.Count(

RestSharp Accept header change

感情迁移 提交于 2019-12-12 08:47:18
问题 I am using RestSharp for developing on the client side. I am also using Ruby Grape gem for my custom API on server side. Grape gem can do versioning by setting Accept HTTP header f.e to application/vnd.twitter-v1+json And test command via console works perfect curl -H Accept=application/vnd.twitter-v1+json /statuses/public_timeline But when I am trying to set up header for RestRequest I am getting error 404 on the server. I have no idea why so. I have found another issue that server returns

Not able to pass list of object to Web API

丶灬走出姿态 提交于 2019-12-12 05:23:07
问题 I am using below code in MVC application Facility fcl = new Facility(); fcl.AD_LN_1 = "aaaaaa"; fcl.AD_LN_2 = "vbbbbbbbbb"; fcl.CITY_NM = "cccccccccc"; fcl.CTRY_CD_ID = "12"; fcl.CTRY_NM = "ddddddddd"; var fclts = new List<Facility>() { fcl }; var url = ConfigurationManager.AppSettings["FCMWebApi.Facility"].ToString(); var client = new RestClient(url); var request = new RestRequest("api/facility/fulladdress",Method.GET); request.RequestFormat = DataFormat.Json; request.AddJsonBody(fclts); var

Is it possible to send HEAD request with RestSharp?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 04:56:44
问题 I'm trying to send HEAD request to server to get a file length from Content-Length header, but I always get 'Not Acceptable' in response when I'm using RestSharp. Id I create request with simple .NET WebRequest it work good. I tried to clear all header and other stuff from request and client, but had no success Is it possible to do this request with RestSharp and how? Thanks in advance 回答1: Try this var request = new RestRequest("/resource", Method.HEAD); 回答2: Solve the problem with

c# Dropbox RestSharp download file to stream

北战南征 提交于 2019-12-12 04:19:27
问题 I have an 'ASP.NET' console application and I use 'RestSharp' client for Dropbox. I use this code to download a file : var baseUrl = "https://content.dropboxapi.com"; var client = new RestClient(baseUrl); client.Authenticator = OAuth1Authenticator.ForRequestToken(mc_apiKey, mc_appsecret); RestRequest request = new RestRequest(string.Format("/{0}/files/auto", mc_version), Method.GET); client.Authenticator = OAuth1Authenticator.ForProtectedResource(mc_apiKey, mc_appsecret, accessToken.Token,

Translate cUrl to restsharp

江枫思渺然 提交于 2019-12-12 03:32:31
问题 I have a cUrl request: curl -v -u admin:geoserver -XPUT -H "Content-type: application/zip" --data-binary @C:\nyc_khr.zip http://localhost:9090/geoserver/rest/workspaces/nyc_roads/datastores/roads/file.shp I need make a request like above, but using C# Example of my code: RestClient client = new RestClient(URL) { Authenticator = new HttpBasicAuthenticator("admin", "geoserver") }; var data = File.ReadAllBytes(somePath); string url = @"rest/workspaces/nyc_roads/datastores/roads/finalas.shx"; var

Windows Phone 8 call WCF web service

不问归期 提交于 2019-12-12 02:34:22
问题 I have been tasked with writing a WP8 application that needs to link to a WCF web service but I can't for the life of me figure out what I am doing wrong I can't change the WCF service, it's not mine The method I am struggling with takes a class as a parameter and returns a different class as the result The interface I have been given for a test method is: [OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json,