restsharp

A route named 'DefaultRoute' is already in the route collection. Route names must be unique

做~自己de王妃 提交于 2019-12-10 14:04:53
问题 When I publish an ASP.NET WebAPI solution to a remote IIS Server , I get the error message: Message: System.ArgumentException: A route named 'DefaultRoute' is already in the route collection. Route names must be unique. I saw this thread with the same problem, but nothing on it has worked. I have tried: Deleting all bin/obj folders in all projects. Cleaning/Rebuilding Deleting files off the the remote server before publishing Renaming the project Is there anyway I can find out if there is a

How to consume JWT access token and user claims using RestSharp

孤街醉人 提交于 2019-12-10 13:46:24
问题 I'm using below code to consume JWT access token from an Asp.net Web Api 2.2 service. I have followed this article to setup an authorization server in Web Api service. I'm using RestSharp in the client. client code: var client = new RestClient(http://localhost:58030); client.Timeout = 30000; var request = new RestRequest(@"/Oauth/Token", Method.POST); request.AddHeader("content-type", "application/x-www-form-urlencoded"); request.AddHeader("grant_type", "password"); request.AddHeader(

How Do I Post Raw Json Using RestSharp?

戏子无情 提交于 2019-12-10 12:54:48
问题 I have an endpoint that takes a Json object that has a message element and then the rest can have different properties. Here's an example: public void SendMessage(IDictionary<string, string> message) { var client = new RestClient(MahUrl); var request = new RestRequest(Method.POST); var json = new JObject(); foreach (var pair in message) { json.Add(pair.Key, pair.Value); } json = new JObject(new JProperty("message", json)); // { // "message": // { // "prop1": "val1", // "foo": "bar", //

RestSharp: UrlEncode in signature base generation returns invalid string

牧云@^-^@ 提交于 2019-12-10 11:42:15
问题 I'm working on twitter client for win8, using RestSharp ( http://restsharp.org/ ) and I have such problem: When I'm posting new tweet with RestClient var timeLine = new RestRequest("/1/statuses/update.json", Method.POST); var txt = "Hello world"; timeLine.AddParameter("status", txt); everything works excelent, but if I add more complex status like: var txt = "Hello, World! What a nice day! #1May"; timeLine.AddParameter("status", txt); I recieve 401 error. In debugger I saw, that status

Cancel a RestSharp Request

你。 提交于 2019-12-10 10:24:48
问题 I'm making a wp7 app that uses RestSharp to download some data. I noticed the application guidelines require that I provide a ui element that allows the user to cancel a data transfer. Is it possible to cancel an ExecuteAsync request with rest sharp? 回答1: ExecuteAsync() returns an RestRequestAsyncHandle which has an Abort() method you can call to kill the request. 来源: https://stackoverflow.com/questions/9216062/cancel-a-restsharp-request

Exceptions with WebAPI Request Formatting

人走茶凉 提交于 2019-12-10 10:15:21
问题 Using the RC version of the MVC4 WebAPI in a project, I keep encountering the following error on the API server side: System.FormatException: The format of value 'application/json; charset=utf-8' is invalid. I've experimented around quite a bit with how I'm calling it from the client side, now using RestSharp like so: var client = new RestClient("http://localhost:29874"); var request = new RestRequest("api/submit", Method.POST); var content = new RestSharp.Serializers.JsonSerializer()

Building XML request with RestSharp

房东的猫 提交于 2019-12-09 17:41:07
问题 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

Why is my Initial call in RestSharp really slow? but others after are very fast

人盡茶涼 提交于 2019-12-09 15:01:22
问题 I am making calls to a WEB API using RESTSHARP and they work fine. However, the Initial call to the API (regardless of what call it is) can sometimes take up to 10 seconds to get a response. Every other call after that is really quick. Does anyone know a way around this? I am running a WPF 4.0 application code: var client = new RestClient(apiAddress); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); 回答1: It's most likely the network settings causing

RestSharp deserialize JSON content(represent an object contains an byte array) error

吃可爱长大的小学妹 提交于 2019-12-09 14:30:41
问题 The Client side receives a formal JSON content "{\"Id\":[1,2,3],\"Size\":56}" , but get an error in deserialization the byte array. 1 Error occurs in the statement below IRestResponse<key> response = client.Execute<key>(request); 2 Error message is "No parameterless constructor defined for this object." 3 The object class in client size is the same as it's in server side: public class key { public byte[] id { get; set; } public int Size { set; get; } } 4 I've tried passing object that

How can I POST (as XML) an object to my ApiController using RestSharp?

我与影子孤独终老i 提交于 2019-12-09 03:23:24
问题 I have an ASP.NET MVC4 website implementing a REST API, which I'm consuming from a client application. My ApiController methods take and return complex objects, as XML. I recently discovered RestSharp, and have begun moving my client project over to that. However, I'm having real problems with it. It seems to almost work - it's so close that I can almost taste success - but I just can't get it to work 100%. The objects I'm passing across the wire look something like this: // The object I'm