restsharp

Getting null values when deserializing a list using RestSharp

六月ゝ 毕业季﹏ 提交于 2019-12-24 09:24:30
问题 I am new to C# and to RestSharp. I am writing a small program to retrieve a list of records via REST. I have been able to retrieve one record. Now I need to get a list of records, and here I have a problem. The response I get using SoapUI looks like this: { "@count": 2, "@start": 1, "@totalcount": 2, "Messages": [], "ResourceName": "email", "ReturnCode": 0, "content": [ {"email": {"evsysseq": "0000000000000262"}}, {"email": {"evsysseq": "0000000000000263"}} ] } My code looks like this: class

Xamarin + RestSharp + .Net Core Web API - Value cannot be null.Parameter name: src

半世苍凉 提交于 2019-12-24 09:08:36
问题 I have a WebAPI in .NET Core 2.1 e I have using the RestSharp to access the API. When I send a request (POST), I always receive the below message in the response: {System.Net.WebException: Error getting response stream (ReadAsync): ReceiveFailure Value cannot be null.Parameter name: src ---> System.ArgumentNullException: Value cannot be null.Parameter name: src at System.Net.HttpWebRequest+d__241 1[T].MoveNext () [0x000ba] in <b78695579ed9422b8bc80218eeda782c>:0 --- End of stack trace from

RestSharp BitStamp Authentication fails

浪子不回头ぞ 提交于 2019-12-24 05:39:18
问题 I'm not able to receive any data from the BitStamp API. What am I doing wrong here? My content form the response results in an error: {"error": "Missing key, signature and nonce parameters"} public ActionResult Index() { const string BaseUrl = "https://www.bitstamp.net/api/balance/"; var client = new RestClient(); var request = new RestRequest(); client.BaseUrl = BaseUrl; AddApiAuthentication(request); var response = client.Execute(request); var foo = response.Content; //{"error": "Missing

Bad Request RestSharp Windows Phone 7

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 03:21:48
问题 I've been trying to make a WCF web service that enters a certain set of data into a database and it can be used in Windows Phone 7. In the configuration file there are two endpoints: json and soap. Here's the code for both of them: <service name="LiveAndesWCF.SightingServiceRest" behaviorConfiguration="MetadataBehavior"> <endpoint address="soap" binding="basicHttpBinding" contract="LiveAndesWCF.ISightingServiceRest"/> <endpoint address="json" behaviorConfiguration="WebBehavior" binding=

How can I get my ServiceStack Tests to authenticate using RestSharp?

不想你离开。 提交于 2019-12-24 01:44:06
问题 I've got a working implementation of CustomCredentialsAuth implemented in my ServiceStack app. I can hit the URL with auth credentials, and it works as expected. In my tests however, I'm not having the same luck. I'm using RestSharp, and if I disable [Authenticate] , I can get all of my tests to pass. Enabling [Authenticate] and running the tests give me Expected: OK But was: Unauthorized Here is my test. How can I get RestSharp to authenticate for my tests? using System; using System.Net;

RestSharp get serialized output

好久不见. 提交于 2019-12-24 01:04:12
问题 I am looking for a way to access the serialized result of the AddBody call. I am using the built in RestSharp Serializer. Example: class Foo { public string FooField; } void SendRecord() { var f = new Foo(); f.FooField = "My Value"; request.AddBody(f); // How do I get the serialized json result of the add body call without // data? I would like to log the serialized output of the add body call to // the database. //Expected {"FooField":"My Value"} var response = client.Execute(request); } 回答1

Console app takes a long time to exit after finishing work

流过昼夜 提交于 2019-12-24 00:42:20
问题 I have a console app that queries a database and then posts some records to a REST API in a loop (the api does not support batch posting, so I have to loop through each record and post individually, if its relevant). The database access is fast and no issue and so is the api post loop according to the timer I've put in place, however the app itself takes a long time to exit after the work is done. This started happening after I introduced Parallel.Foreach to speed up the posting. Before using

Convert curl command to restsharp

谁说我不能喝 提交于 2019-12-24 00:25:48
问题 How to convert this curl command to restsharp? curl -X POST \ --header "Authorization: Bearer SomeToken" \ --header "_Id: SomeId" \ --data-urlencode 'keys: name, age' \ https://api.SomeDomain.com/object-storage/classes/query/Player I've tried this: RestClient client = new RestClient("https://api.SomeDomain.com"); RestRequest request = new RestRequest("/object-storage/classes/query/hotels", Method.POST); request.AddHeader("_Id", "SomeId"); request.AddHeader("Authorization", "Bearer " +

RestSharp “Error getting response stream (ReadAsync): ReceiveFailure Value cannot be null. Parameter name: src”

耗尽温柔 提交于 2019-12-23 19:00:15
问题 Hello all am trying to do a login to my xamarin api using RestSharp, the API ought to return status code 200 OK if the authentication works and status code 415 if the authentication fails(wrong password) and other codes depending on what the case scenario, but instead i get a status code 0 on all other case asides when the authentication pass(status code 200 ok), the source code below is how i implement //payload am sending to the api RequestPayload res = new RequestPayload(); res.appid =

RestSharp Unit Test NUnit Moq RestResponse null reference exception

余生颓废 提交于 2019-12-23 12:24:28
问题 I'm having some challenges trying to use Moq with RestSharp. Maybe it's it my misunderstanding of Moq but for some reason I keep on getting a null reference exception when trying to Mock a RestResponse. Here is my unit test. [Test] public void GetAll_Method_Throws_exception_if_response_Data_is_Null() { var restClient = new Mock<IRestClient>(); restClient.Setup(x => x.Execute(It.IsAny<IRestRequest>())) .Returns(new RestResponse<RootObjectList> { StatusCode = HttpStatusCode.OK, Content = null }