restsharp

RestSharp AddFile adding multipart form headers to file

血红的双手。 提交于 2020-02-02 12:34:01
问题 I'm using RestSharp's AddFile and it's working close to fine except my files end up getting broken due to this header information that's being added. -------------------------------28947758029299 Content-Disposition: form-data; name="user.png"; filename="user.png" Content-Type: image/png This was just a test image I uploaded. If I remove these lines from the file then it opens fine, otherwise it seems to be corrupt. Is it possible for me to use AddFile without this stuff getting added?

RestSharp AddFile adding multipart form headers to file

佐手、 提交于 2020-02-02 12:32:06
问题 I'm using RestSharp's AddFile and it's working close to fine except my files end up getting broken due to this header information that's being added. -------------------------------28947758029299 Content-Disposition: form-data; name="user.png"; filename="user.png" Content-Type: image/png This was just a test image I uploaded. If I remove these lines from the file then it opens fine, otherwise it seems to be corrupt. Is it possible for me to use AddFile without this stuff getting added?

Unable to get Access token and Refresh token

情到浓时终转凉″ 提交于 2020-02-01 07:29:19
问题 All ClientID, ClientSecret & RedirectURI placed in the web.config . <appSettings> <add key="redirectURI" value="http://localhost:55593/oauthplayground" /> <add key="clientId" value="uX4YpHHNm****ltekoG" /> <add key="clientSecret" value="K5cSv3izT1GZ9PXnaWWfRWbTv10*****O3JkYFMlWMF3FhBtjyk0FqJduGJZSAL7B1DngJyxgX3KKNSD0Bqdv" /> </appSettings> Now from here I got the authentication code. static string redirectURI = ConfigurationManager.AppSettings["redirectURI"]; static string clientID =

Unable to get Access token and Refresh token

a 夏天 提交于 2020-02-01 07:28:25
问题 All ClientID, ClientSecret & RedirectURI placed in the web.config . <appSettings> <add key="redirectURI" value="http://localhost:55593/oauthplayground" /> <add key="clientId" value="uX4YpHHNm****ltekoG" /> <add key="clientSecret" value="K5cSv3izT1GZ9PXnaWWfRWbTv10*****O3JkYFMlWMF3FhBtjyk0FqJduGJZSAL7B1DngJyxgX3KKNSD0Bqdv" /> </appSettings> Now from here I got the authentication code. static string redirectURI = ConfigurationManager.AppSettings["redirectURI"]; static string clientID =

RestSharp returns object with null values

蓝咒 提交于 2020-01-25 04:05:05
问题 I'm using RestSharp 106.6.10. I expect the response to return a simple object with four string properties. I've defined the object's class in C# with the correct property types, spelling, and capitalization. I'm posting a request and getting a response with no errors. The response's Content appears to be clean JSON, with a Data object that includes good values for my "TransactionAcknowledgement" object. But here's my problem: the Data object returned by RestSharp has null values for the

Call works in Postman but not in C#

亡梦爱人 提交于 2020-01-22 03:28:31
问题 I am trying to make a call to below URL and it works just fine in Browser (Chrome) and also in Postman, but for some reason, it doesn't work in C#. Working in browser: http://AJWKBLWT47VR26QWPNFCPJLXC6217F6F@presta.craftingcrow.com/api/categories Working in Postman: http://AJWKBLWT47VR26QWPNFCPJLXC6217F6F@presta.craftingcrow.com/api/categories Not working in C# (RestSharp): var client = new RestClient("http://AJWKBLWT47VR26QWPNFCPJLXC6217F6F@presta.craftingcrow.com/api/categories"); var

How can I catch exceptions with RestSharp [closed]

大城市里の小女人 提交于 2020-01-20 21:45:30
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 days ago . I am working on a project with RestSharp. Over time I discovered several exceptions that RestResponse class can throw, most of which I have to handle so my app doesn't crash. How can I know of all possible exceptions and handle them individually. 回答1: RestResponses and Errors This

Register IRestClient with different API URLs with Simple Injector

笑着哭i 提交于 2020-01-17 05:52:12
问题 I would like to register IRestClient with Simple Injector to inject it into a service: public class ActiveCustomersService : IActiveCustomersService { private readonly Uri apiUri = new Uri(string.Format("{0}/{1}", ApiHelper.GetUrl(), thisApiUrl)); private IRestClient _client; public ActiveCustomersService() { _client = new RestClient(apiUri); } public ActiveCustomersService(IRestClient client) { _client = client; } } However when I am trying to register it: private void

RestSharp requests on momentapp's restful api

纵饮孤独 提交于 2020-01-15 06:59:52
问题 So Im trying to set up RestSharp to use Moment Task scheduling according to the docs http://momentapp.com/docs here is my code. public class MomentApi : ITaskScheduler { const string BaseUrl = "https://momentapp.com"; private RestResponse Execute(RestRequest request) { var client = new RestClient(); client.BaseUrl = BaseUrl; request.AddParameter("apikey", "MYAPIKEYHERE", ParameterType.UrlSegment); // used on every request var response = client.Execute(request); return response; } public

RestSharp to WCF as JSON date formatting / serializing

无人久伴 提交于 2020-01-14 14:32:32
问题 I have a WCF Method that takes in a list of "Timestamps" public bool SyncTimestamps(IList<Timestamp> timestamps) For the life of me I cannot get the client to pass values to the host in a format that it is happy with using RestSharp. The problem appears to be with dateformatting. Attempt 1 var request = new RestRequest("Timestamp/SyncTimestamps", Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(timestamps); Output 1 "[{\"ID\":1,\"JobId\":654321,\"TimestampSelected\":\