0

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

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

-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

3 Comments

what does the "Bearer" stands for and wont i need to specify the request content type like "application/json" ?
When sending requests to APIs you often need an Authentication Token, this token needs a security scheme and in this case it is Bearer. There are times you need to set Content Type but based on your curl command there is no need. I Will update my answer to include changing the content type of the request.
this is my first time with curl but your reply have really put me in place. wish i could connect with you better, thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.