restsharp

I am trying to deserialize JSON data to a dataset

大憨熊 提交于 2019-12-11 06:22:13
问题 I thought JSON was supposed to be easy to use. I have a C# .NET Windows form program in Visual Studio 2015 being used as a client consuming a Web API 2 remote server with RestSharp as the HTTP client. the data returned from the API call is in Json format. However, when I try to deserialize the returned Json into a dataset using this statement: DataSet data = (DataSet)JsonConvert.DeserializeObject(response.Content, (typeof(DataSet))); , I get this error: "Unexpected JSON token while reading

RestSharp :Getting null from the result.Data althouh at the time of debug result has JSON returned

扶醉桌前 提交于 2019-12-11 05:56:19
问题 I am using RestSharp and trying to deserialize the JSON result set and when I run the code I'm getting null from the result.Data although at the time of debugging the result has JSON returned. private static void GetPanelList() { var client = new RestClient("http://CCCCCC.XXXXXX.com/API/v3/mailinglists/ML_dfgfghfghfh/contacts"); var request = new RestRequest(Method.GET); request.AddHeader("cache-control", "no-cache"); request.AddHeader("x-api-token", "JHFKFKJFYILIOROIY"); // IRestResponse

C# RESTSharp client connect Drupal Rest_server Access denied for user anonymous

我的未来我决定 提交于 2019-12-11 05:26:38
问题 I was search this article Consuming Drupal RestApi with c# And http://tylerfrankenstein.com/code/drupal-services-csrf-token-firefox-poster I has question in the cookie and token. I have test in poster with firefox and successful on post the created article .Tamper Data has the request header. tamper data nid: "129342" uri: http://www.tsghy.com.cn/services/node/129342 Postman created the post code var client = new RestClient("http://www.tsghy.com.cn/services/node"); var request = new

How to send group separator (non printable ascii characters) with RestSharp RestClient from C#

只谈情不闲聊 提交于 2019-12-11 03:43:03
问题 Updated I have completely reworked this question and included a complete working example. My succinct question is now: How come I'm not seeing individual characters of string "\u001d" when I use RestSharp RestClient and pick json as the RequestFormat options to send a simple object to a server? I send the output to a test server, and see only 1d when I examine the output with a binary editor. I would expect 5C 75 30 30 31 64 ('\','u','0','0','1','d') AND that is what you see if you just use

REST Windows Phone Photo upload

青春壹個敷衍的年華 提交于 2019-12-11 02:37:37
问题 I'm trying to upload a photo to a REST api in a Windows Phone 7 application using RestSharp for my Gets/Posts. The post parameters are as follows: photo : The photo, encoded as multipart/form-data photo_album_id : Identifier of an existing photo album, which may be an event or group album I've created my request, but every time I get back "{\"details\":\"missing photo parameter\",\"problem\":\"The API request is malformed\"}\n My photo parameter looks like this: "--------------------------

Upload File using RestClient as multipart/form-data in c#

孤者浪人 提交于 2019-12-11 00:45:31
问题 I am trying to upload files from the c# class using restClient (RestSharp) request. I am creating Method.POST method and add one Audio file to this request As multipart/form-data. Server throws an exception when I execute the request. Exception : System.ArgumentNullException: Value cannot be null. Parameter name: value at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult) at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase) at

How to XmlDeserialize using RestSharp?

♀尐吖头ヾ 提交于 2019-12-10 23:17:57
问题 I'm having trouble deserializing the following XML w/ restsharp <Xid> <Id>118</Id> <Active>true</Active> <Xid>20</Xid> <CreatedDate>2011-09-16T18:15:32</CreatedDate> <CreatedUserId>1782</CreatedUserId> <ModifiedDate>2011-09-16T18:15:32</ModifiedDate> <ModifiedUserId>1782</ModifiedUserId> <TableName>ProjectRate</TableName> <ObjectId>644</ObjectId> <SystemGuid>157f2e2d-5e8b-41c7-b932-09c1d75d0ccc</SystemGuid> </Xid> I can't use a class named 'Xid' with a member named 'Xid' as there is a

RestSharp JsonDeserializer with special characters in identifiers

北城以北 提交于 2019-12-10 19:29:39
问题 I have some JSON coming from Last.fm like this: { "toptags":{ "@attr":{ "artist":"Whatever", "album":"Whatever" } } } Is there a special way to setup RestSharp to get it to recognize the @attr ? The @ (AT sign) is causing me problems because I can't create an identifier that will match this. 回答1: From looking at the RestSharp source it's possible to enable it to do data contract deserialization, this seems to require a change of the RestSharp source. Search for //#define SIMPLE_JSON

MVC4 WebApi Serialization/Deserialization MongoDB ObjectId

别来无恙 提交于 2019-12-10 16:59:18
问题 I am using MVC4 WebApi with a RestSharp client and I am struggling to get ObjectIds to serialize (or deserialize) properly. I have a basic class like so: public class User { [BsonId] public ObjectId Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } What is the best/proper way to deserialize this object on the client? Everything I have tried the Id property is of value ObjectId.Empty. Update I have tried a creating a different ObjectIdDeserializers.

Why is RestSharp AddHeader(“Accept”, “application/json”); = to a list of item?

痴心易碎 提交于 2019-12-10 15:10:39
问题 I've got this Windows Phone 8 project in C#, where I'm using RestSharp 104.4.0 to make a request to a server. The server only accepts a "Accept" type of "application/json". My code to call the request: var client = new RestClient(_jsonBaseUrl + someURL) { Authenticator = new HttpBasicAuthenticator(someUsername, somePassword) }; var request = new RestRequest(Method.POST); UTF8Encoding utf8 = new UTF8Encoding(); byte[] bytes = utf8.GetBytes(json); json = Encoding.UTF8.GetString(bytes, 0, bytes