N.Olsen
N.Olsen

Reputation: 63

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("http://www.ocrwebservice.com");
            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);
        }
}
}

I'm 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 can't 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.

Upvotes: 6

Views: 14727

Answers (3)

nesterenes
nesterenes

Reputation: 232

Upgrading from version 110.2.0 to 111.0.0 required changing HttpBasicAuthenticator to HttpBasicAuth.

Upvotes: 1

rameshsriram
rameshsriram

Reputation: 39

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

Upvotes: 0

NikolaiDante
NikolaiDante

Reputation: 18639

Try

using RestSharp.Authenticators;

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

Upvotes: 13

Related Questions