C#, RestSharp, Type or Namespace name "HttpBasicAuthenticator" could not be found

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Net.Http; using System.Net.Http.Headers; using RestSharp; namespace ConsoleProgram { public class TryingOutRest { public resttest Execute<resttest>(RestRequest request) where resttest : new() { var client = new RestClient(); client.BaseUrl = new Uri(""); client.Authenticator = new HttpBasicAuthenticator("apid", "apikey"); // the key and and id are put in as a string, but i removed them for the purposes of this. var re_quest = new RestRequest(); re_quest.Resource = "/restservices/processDocument"; var response = client.Execute<resttest>(request); } } } 

So, hi, trying to get to grips with Rest api, Currently doing a project involving it and OCR, as you can probably tell. Tried this, i thought it would work fine, but I seem to have messed up dearly or some naming has changed and i cant find anything relevant in the autofill menu. Anyone got any idea what's happening? P.s. if questions about install, i used NuGet for that, so i assume there'd be no problem.

2 Answers

Try

using RestSharp.Authenticators; 

This seems to be the namespace for HttpBasicAuthenticator now. (Github)

1

Open Nugetpackage manager and install RestSharp Then you can use using RestSharp.Authenticators

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like