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#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

Answer accepted by question author
  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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.