401 error with Client SDK

I’m trying to connect to API using Clinet SDK for C# and I’m constantly getting 401 error:

var restClient = new RestClient(api_key_id, secret_key, alpacaRestApi: endpoint, apiVersion: 1);
var asset = await restClient.GetAssetAsync(“AAPL”);

Any help greatly appreciated.

did you try api V2?..

Yes. I started with version 2 but it was the same.

paper trading or live and what’s the end point ? id need to see most of the code to help you.

look into the var alpacaRestApi and make sure its calling the correct address

Endpoint url is just paper trading url but it seems like only api key and secret key are mandatory. I got the same 401 no matter how many params i put in.

Do i need to add rest part like /v2/acconut to endpoint api?

No I think it might be something to with certificates cause I had same issue when using curl commands and then I added --ssl-no-revoke and it started to work.
Anyway turned away from ClientSDK to code below and it works fine:
var client = new HttpClient();
var request = new HttpRequestMessage();
request.Method = new HttpMethod(“GET”);
request.Headers.Add(“APCA-API-KEY-ID”, “”);
request.Headers.Add(“APCA-API-SECRET-KEY”, “”);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(“application/json”));
request.RequestUri = new Uri(“https://paper-api.alpaca.markets/v2/account”, UriKind.RelativeOrAbsolute);
var response = await client.SendAsync(request);
var content = response.Content.ReadAsStringAsync();