-3

i was trying to receive the response after API call without success. tha API call needs header. this is my code:

        private static readonly string url = "https://evtradepro.net/wp-json/mp/v1/me";
    public static async Task<string> Authorization()
    {
        var request = new HttpRequestMessage();
        request.RequestUri = new Uri(url);
        var client = new HttpClient();
        client.DefaultRequestHeaders.Add("MEMBERPRESS-API-KEY: WWWWWWWW", "application/json"); 
        var response = await client.SendAsync(request);
        HttpContent content = response.Content;
        string mycontent = await content.ReadAsStringAsync();
        return mycontent;
    }
Coder
  • 1

1 Answers1

0

client.DefaultRequestHeaders.Add() takes two arguments: the first is the key, and the second is the value

ahmad arab
  • 26
  • 4
  • thank you, the line of client.DefaultRequestHeaders.Add() was fixed, but i have this error: "Impossible de créer un canal sécurisé SSL/TLS." – Coder Jul 08 '21 at 19:03
  • TLS issue: https://stackoverflow.com/questions/22251689/make-https-call-using-httpclient – Mike Jul 08 '21 at 19:28