question

norbi avatar image
norbi asked bryanvargas edited

working C# example

can someone share a working c# example that connects to clover and extract order list? i try the sample from website but i get 401 unautorised back.

Production
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

bryanvargas avatar image
bryanvargas answered bryanvargas edited

401 is generally tied to expired/invalid token. I would suggest checking your OAuth/acessToken.

C# HttpClient Ex:


var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://sandbox.dev.clover.com/v3/merchants/{mId}/orders");
request.Headers.Add("Authorization", "Bearer {accessToken");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());




C# RestSharp Ex:

var options = new RestClientOptions("https://sandbox.dev.clover.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/v3/merchants/{mId}/orders", Method.Get);
request.AddHeader("Authorization", "Bearer {accessToken");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community