HttpRequestMessage using API Key

Dave Gray 586 Reputation points
2021-11-30T10:47:07.433+00:00

Hello

I have an API that I need to POST to from within a C# application. I have the posts working correctly within Postman but
I cannot seem to get the corresponding code working in a Console application. The format of the authentication in Postman
is "API Key" with a key/value pair.

To be honest I am not sure how to map the authorization into C# code, so probably the attached example is wrong.

Does anyone have an example of how to add this key/value pair to the headers and/or have any comments on if I should be adding the
values or use the byte[] that I got from some working code that used "Basic" authentication

153721-image.png

153647-image.png

My code example is just from a sandpit test.

Thanks in advance.

Developer technologies ASP.NET Other
Developer technologies C#
{count} votes

Accepted answer
  1. Dave Gray 586 Reputation points
    2021-12-01T15:38:44.49+00:00

    For anyone reading this in future this was how I solved it using RestSharp.

    154166-image.png

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.