restsharp

RestSharp PUT XML, RestSharp is sending it as GET?

瘦欲@ 提交于 2019-12-06 14:54:27
问题 I am attempting to edit a product using the prestashop API, using RestSharp in C#, using XML. The documentation's instructions are as follows: To edit an existing resource: GET the full XML file for the resource you want to change (/api/customers/7), edit its content as needed, then PUT the whole XML file back to the same URL again. I am attempting to edit /customers/1. My GET calls are working fine to retrieve the data. I am now deserializing the data, editing it as needed, and re-saving to

example of parsing a receipt for an in-app purchase using iOS Xamarin?

北城余情 提交于 2019-12-06 14:18:02
问题 I am trying to implement purchase validation for my app. I see that I can send the purchase receipt to my server to verify with Apple. However, I cannot figure out the correct way to POST the NSData to my URL for validation. Something like this: public void CompleteTransaction (SKPaymentTransaction transaction) { var productId = transaction.Payment.ProductIdentifier; NSUrl receiptURL = NSBundle.MainBundle.AppStoreReceiptUrl; NSData theData = NSData.FromUrl (receiptURL); RestRequest request =

How to handle return values in async function

陌路散爱 提交于 2019-12-06 12:46:14
When working on data APIs which use async rest calls (I am using RestSharp.Portable), what is the best way to handle return values? Since async function can only return a Task or Task ... but the caller has no way to getting back to the return value ... how would the API return data back to the caller? Global properties? From what I have read so far, it appears that callback functions are the only way to interact with Response Data? Take the following method for example; previously I was not using async Rest library and was able to return a value but after converting it to use RestSharp

How I deserialize a dynamic json property with RestSharp in C#?

亡梦爱人 提交于 2019-12-06 11:29:28
I have a web service (I can't edit) with this structure: /users { "response" : { "users": [{"name": "John"},{"name": "Jack"}] }, "page" : { "current":1, "total":1} } /pets { "response" : { "pets": [{"name": "Fido"},{"name": "Tweety"}] }, "page" : { "current":1, "total":1} } As you can see the property name in the "response" property changes. How can deserialize a generic response with RestSharp? I don't want to write a Response class for every resource. I have written the following generic Response class class RestResponse{ public ResponseBody response { get; set; } public ResponsePage page {

Adobe Sign (echo sign) API sending document using C#

谁都会走 提交于 2019-12-06 11:29:14
问题 Okay I have limited understanding of working with API's Im trying to get to grips with Adobe Sign API and hit a dead end, on there test page i have enterd this and it works But i have no idea on how then do that in C# I have tried the following, but know its missing the OAuth stuff and I'm just not sure what to try next. by the way foo.GetAgreementCreationInfo() just gets the string that is in the screen shot, I just moved it out cus it was big and ugly var foo = new Models(); var client =

RestSharp - How to handle non-200 responses? RestClient throws exception on Execute

有些话、适合烂在心里 提交于 2019-12-06 08:14:07
问题 I'm using RestSharp in Windows Phone 8.1 application. RestClient throws exception when server returns response with code different than 200. Wiki says that I should get response with correct status code. I want to get content of response because server returns error messages. private async Task<T> ExecuteAsync<T>(IRestRequest request) { if (!_networkAvailableService.IsNetworkAvailable) { throw new NoInternetException(); } request.AddHeader("Accept", "application/json"); IRestResponse<T>

Restsharp: Deserialize json object with less/more fields than some class

一世执手 提交于 2019-12-06 07:09:41
问题 I'm using Restsharp to deserialize some webservice responses, however, the problem is that sometimes this webservices sends back a json response with a few more fields. I've manage to come around this so far by adding all possible field to my matching model, but this web service will keep adding/removing fields from its response. Eg: Json response that works: { "name": "Daniel", "age": 25 } Matching model: public class Person { public string name { get; set; } public int age { get; set; } }

Mvc4 RTM validation throwing an error

我的未来我决定 提交于 2019-12-06 03:31:20
问题 Has something changed with the rtm bits regarding the validation of models. I have a simple viewmodel that looks like public class ProductViewModel { [Required] [DataMember(IsRequired = true)] public int ProductTypeId { get; set; } public string Product { get; set; } } (I just added the DataMember(IsRequired = true) as the error message I get says to use it to fix the problem. However no joy) Within my controller the model state is telling me model is valid however when I try passing the

Exceptions with WebAPI Request Formatting

我只是一个虾纸丫 提交于 2019-12-06 01:58:45
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().Serialize(myDto); request.RequestFormat = DataFormat.Json; request.AddBody(content); var restResponse = client