I am having problems converting a curl command to c# code.
I have been given a curl command which includes an API key as follows:
curl -k -u x:459c4da6401d39bbf9327ee17175e25c
-H "Content-Type: application/json" https://disney.com/v1/services.json
When I watch this call in Fiddler I can see a header value that looks like this:
Authorization: Basic eDo0NTljNGRhNjQwMWQzOWJiZjkzMjdlZTE3MTc1ZTI1Yw==
So, the curl command is working perfectly... But I cannot replicate it in c# code
I don't understand how the x:459c4da6401d39bbf9327ee17175e25c
has changed to Authorization: Basic eDo0NTljNGRhNjQwMWQzOWJiZjkzMjdlZTE3MTc1ZTI1Yw==
And subsequently, I am confused how to get my c# code to change from the API key to what I am seeing in Fiddler.
When I use this code to add a header the authorisation fails:
httpWebRequest.Headers.Add("Authorization", "459c4da6401d39bbf9327ee17175e25c");
I have also tried:
httpWebRequest.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes("459c4da6401d39bbf9327ee17175e25c"));
But that produces a header value of this:
Authorization: Basic NDU5YzRkYTY0MDFkMzliYmY5MzI3ZWUxNzE3NWUyNWM=
Can anyone help please?
Thanks