HttpRequestMessage using API Key

Dave Gray 581 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.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,326 questions
C#
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.
10,414 questions
{count} votes

0 additional answers

Sort by: Most helpful