Reputation: 91
i try to work around converting this to c# but i cant understand the tags like -H others am familiar with like the BVN and secret key are clear to me, but i'm literally at cross road.
curl https://api.paystack.co/bank/resolve_bvn/:BVN
-H "Authorization: Bearer YOUR_SECRET_KEY"
-X GET
this enlightened me but i'm new to using curl
Upvotes: 0
Views: 705
Reputation: 484
-H means the headers of the request. In C# the code would look something like this:
private static HttpClient httpClient = new HttpClient();
var uri = new Uri("https://api.paystack.co/bank/resolve_bvn/:BVN");
var reqMessage = new HttpRequestMessage(HttpMethod.Get, uri);
reqMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "YOUR_SECRET_KEY")
// Setting the request content (including content-type)
reqMessage.Content = new StringContent("Content of request", Encoding.UTF8, "application/json");
var resp = await httpClient.SendAsync(reqMessage);
You can read more HttpClient and API requests in C# here:
https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=netcore-3.1 https://learn.microsoft.com/en-us/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client
Upvotes: 0
Reputation: 5002
I only want to explain command flags.
-H
means request header. In your case, you need to set header with name Authorization to the secret key Bearer YOUR_SECRET_KEY eg Bearer abcd123566 where abcd123566 is your secret key.
-X GET
means your request method (HTTP verb) should be GET
Upvotes: 1