I'm working on a C# console application which calls external REST APIs with RestSharp.
The issue now is that I have to access an API that only allows a custom request method like FOOBAR
instead of the traditional GET
or POST
.
using RestSharp;
var request = new RestRequest();
request.Method = Method.POST;
Unfortunately, I haven't seen anything pertaining to custom request methods in RestSharp's docs or GitHub issues section.
Keep in mind that I only have a basic knowledge on this, so my trials might be considered silly.
I've tried assigning a string to it but it only accepts an enum.
request.Method = "FOOBAR"; // Does not accept strings
I've also tried converting a string to enum using code from this answer, but this defaults to a GET
. It might be like that due to my converted string not being in their enum Method.
Enum.TryParse("FOOBAR", out Method customRequestMethod);
request.Method = customRequestMethod; // Defaults to GET
If this is not possible with RestSharp, is this feature doable with HttpClient or Flurl?