restsharp

Network errors on wp7

孤者浪人 提交于 2019-12-12 01:36:57
问题 I'm trying to build and run old application which worked fine several month ago on wp7, however none of http clients works for me. First, i'm trying HttpWebRequest var httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.Method = HttpMethod.Get; httpWebRequest.Accept = "application/json"; var response = (HttpWebResponse)await httpWebRequest.GetResponseAsync(); it throws an exception The remote server returned an error: NotFound. Then i tried HttpClient Uri theUri = new Uri(

RFC on HttpWebRequest vs RESTSharp from Windows CE / Compact Framework 3.5

痞子三分冷 提交于 2019-12-12 00:52:15
问题 I created a simple WebAPI service in .NET4 and Visual Studio 2010. I need to consume that service in a Windows CE / CF 3.5 app I do have HttpWebRequest available to me, but am not sure if this is the way to go, or I should use RestSharp. Does anybody have insight/experience that would help me decide? I prefer not using 3rd party code when possible to avoid it, but am willing to do so if there is a clear advantage over the "raw" offerings. Does anyone have, or know of, examples for accessing

RestSharp XML Deserialization into List

陌路散爱 提交于 2019-12-11 21:19:45
问题 I am trying to deserialize the following xml using RestSharp, but I always get a list of null elements. I am new to REST based services and need some expert help! =) Solution Found : I figured it out. You have to explicitly tell RestSharp what kind of data is being deserialized: request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; }; Full XML: http://autocomplete.wunderground.com/aq?query=San%20F&format=xml Some of the XML is below: <RESULTS> <name>San Francisco,

Datetime property is not binding causing the model to be null.

好久不见. 提交于 2019-12-11 18:42:09
问题 My WebAPI is expecting a model like below: Model: public class MyModel { public DateTime datetime {get;set; } } WebAction Method: public IHttpActionResult Post([FromBody] MyModel model) I am using RestSharp to send a request. var restRequest = new RestRequest(url, Method.POST) { RequestFormat = DataFormat.Json, }; restRequest.AddBody(new MyModel {Datetime =DateTime.Now}, ""); But the model binding is always null (in the webapi side). I see the following in Fiddler: {"datetime":"2014-09-25T07

Restsharp not giving any response

99封情书 提交于 2019-12-11 15:34:33
问题 I am developing an Android app in Xamarin.Android and I want to access a Web API (hosted on local IIS) using RestSharp. When I run the app it doesn't give any result nor give any error. Here is my code var client = new RestClient("http://localhost:8066/Student/?id=193"); var request = new RestRequest("", Method.GET); IRestResponse response = client.Execute(request); var content = response.Content; Console.WriteLine("Response: " + content); 回答1: Follow the documentation, when creating a

Bad Request when trying to add JSON body to request with RestSharp

跟風遠走 提交于 2019-12-11 13:52:11
问题 So for the last 2 days I have been trying to add a new issue on a github repository. This seems fairly simple. The documentation says to just add some JSON and then send it on its way. I first make an issue: public class RequestIssue { public string title { get; set; } public string body { get; set; } public string assignee { get; set; } public int milestone { get; set; } public List<string> labels { get; set; } } and then create a call using RestSharp string text = JsonConvert

Box -> View API -> Can not create session for an document_id

ⅰ亾dé卋堺 提交于 2019-12-11 09:58:49
问题 To follow the instruction of Box.com View API on how to create a session curl https://view-api.box.com/1/sessions \ -H "Authorization: Token YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"document_id": "ABC123"}' \ -X POST I use RestSharp to write code: var client = new RestClient("https://view-api.box.com/1/sessions"); RestRequest request = new RestRequest(Method.POST); request.RequestFormat = DataFormat.Json; request.AddHeader("Authorization", "Token

Json dictionary result deserialization with RestSharp/Newtonsoft.Json.

谁都会走 提交于 2019-12-11 09:52:58
问题 I am using restsharp and a newtonsoft.json in order to communicate with my Python API. Communications works fine. Basic queries, which return simple strings are processed, so that's not a problem. I have problem with deserialization of more complex results and i am doing this for the first time. So, from web service point of view i am returning following json structure: { "Employee": [ { "Department.DepartmentName": "IT", "Employee.EmployeeArchived": 0, "Employee.EmployeeDepartmentId": 13,

Serializing a class to xml using RestSharp.AddBody fails

被刻印的时光 ゝ 提交于 2019-12-11 07:54:26
问题 I try to add a simple test-class to a RestSharp-RestRequest via the RestRequest.AddBody -Method. I tried to serialize using both of the delivered serializers, but i could not get one of them to work (JSON-Serializations works pretty fine with just the same settings...) This is how i do the serialization: private void SerializationTest() { RestRequest request = new RestRequest(); request.XmlSerializer = new RestSharp.Serializers.DotNetXmlSerializer(); //request.XmlSerializer = new RestSharp

RestSharp post object to WCF

走远了吗. 提交于 2019-12-11 06:38:34
问题 I am having an issue posting an object to my WCF REST Web Service. On the WCF side I have the following: [WebInvoke(UriTemplate = "", Method = "POST")] public void Create(myObject object) { //save some stuff to the db } When I am debugging, the break point is never hit.However, the break point is hit when I remove the parameter.So, I am guessing I have done something wrong on the RestSharp side of things. Here's my code for that part: var client = new RestClient(ApiBaseUri); var request = new