Questions tagged [restsharp]

RestSharp is a simple to use REST client library for .NET

RestSharp takes the pain out of calling REST services from .NET. This library takes care of the quirks in .NET's HTTP classes, handles deserialization cleanly, simplifies making asynchronous calls, and just makes it really easy to implement calls to REST services from inside your application.

RestSharp comes with a built-in JSON serializer. The default serializer has been compatible with the Json.NET project but this compatibility has been given up since release 100.3.

Installation Installing RestSharp can most easily be done using its NuGet package:

Install-Package RestSharp

Resources

2486 questions
0
votes
2 answers

RestSharp - bad converting string to json c#

Hello dunno why but when i try POST with RestSharp there is something bad with converting data. I'm trying to post data with baselinker: API : https://api.baselinker.com/index.php?tester When i just post with thier test on website it's good response…
Adam Zbudniewek
  • 107
  • 2
  • 12
0
votes
0 answers

How to make a Post request by pushing ND-JSON file using RestSharp?

I'm trying to get the RestSharp (v107) equivalent of the following cURL command: curl --insecure -H "Content-Type: application/x-ndjson" -XPOST -u user:password https://localhost:9200/products/_bulk --data-binary…
Vignesh
  • 35
  • 4
0
votes
0 answers

REST Api Put Request Problem (RestSharp) to Netapp REST Api. Getting always "Invalid JSON input"

In my C# app I access a NetApp REST API. I am using RestSharp to access the API. No problem with Get requests. However when I try a Put request I alwas get: "Invalid JSON input. Unexpected character in stream: r around 0:0." Added: I'm stuck with…
0
votes
1 answer

RestSharp version > 107: How to implement NtlmAuthenticator?

I got a source code from a colleague in which using RestSharp (version 106.15.0) in VB.NET retrieves data from a web api. I updated the RestSharp version to 108.0.1 and the code no longer works. I found out that some things have changed with…
Mec-Eng
  • 199
  • 10
0
votes
1 answer

Translating HttpClient generic code to RestSharp

I'm trying to convert the HttpClient code to RestSharp but unsuccessfully. My attempt is below. I'm not sure whether HttpClient's request.Content can be translated to request.AddStringBody There is a compile time error at this line…
nop
  • 4,711
  • 6
  • 32
  • 93
0
votes
0 answers

Do I need HttpUtility.UrlEncode here?

I've seen some people using HttpUtility.UrlEncode on each one of the parameters. Do I need to do the same in the GetCashBalanceAsync method below which uses RestSharp? private static string BuildQueryString(Dictionary
nop
  • 4,711
  • 6
  • 32
  • 93
0
votes
1 answer

How can I translate this three part Curl command to RestSharp?

I am trying to use an API and the example they have given is in the form of a Curl command: curl --location --request POST 'https://dev-api.itranslate.com/translation/v2/' --header 'Authorization: Bearer 603160b7-cee1-4c13-bcd7-37420b55211d'…
0
votes
2 answers

RestSharp.RestClient 107 in Azure Function throws "The type initializer for NAME threw an exception". No issue in RestSharp 106.10

In an Azure Function a static helper class uses RestSharp 106 like this: public static class InsightlyHelper { private static readonly RestClient RestClient = new RestClient { BaseUrl = new…
0
votes
0 answers

NetSuite REST Webservice C# RestSharp - Request failed with status code BadRequest

I continue to bang my head against the wall on this call. It returns perfectly fine in postman, but when I run through VS I get the following: Exception Message: One or more errors occurred. (Request failed with status code BadRequest). Exception…
warrenk
  • 119
  • 1
  • 7
0
votes
1 answer

Error while creating a WorkItem via API - Devops

I'm trying to create a workitem via API, but im getting the following error: { "innerException": null, "message": "You must pass a valid patch document in the body of the request.", "typeName":…
0
votes
1 answer

Why does RestSharp Call work in VB.NET form Code module, but not in VB.NET class module with same code

This is a continuing quest to get api calls to work in in VB.NET application using RestSharp. When I started this effort I created a Windows forms project so I could manually enter values and test the approach. The first task in running the…
DougM
  • 109
  • 3
  • 16
0
votes
0 answers

Application not establishing Tls1.2 connection

This seems to be a continuation of several issues I have posted questions about. I have an application that queries an eBay api for a user token when posting a refresh token. I created a test application in VB.Net where I supply the user refresh…
DougM
  • 109
  • 3
  • 16
0
votes
1 answer

How to setup In memory cache for RestSharp Client in .NET Core Console Application

I have C# console application in .NET 6. I am researching the setup of a RestSharp client first i need to setup in memory caching. I have done an implementation in asp.net that uses System.Runtime.Caching Example of the difference : public class…
Steve020
  • 125
  • 1
  • 10
0
votes
0 answers

Make parallel calls using RestSharp without instantiating RestClient for every call

I've got a .NET Standard 2.0 library that's used by a variety of projects (.NET Framework, .NET Core, UWP, Xamarin, etc.). It's basically a data client that projects can call to get data from web service API methods. I'm trying to figure out how to…
NeilN
  • 29
  • 5
0
votes
1 answer

Posting a file with a raw XML using RestClient

I've been using similar XML Posts with success....just that this one calls for ProofPDF which is a byte array. How can I populate this XML Tag properly... I'm getting an invalid request at the moment. public async void Post(List
Pinch
  • 4,009
  • 8
  • 40
  • 60