Jump to content









Photo

C# httpclient get value


  • Please log in to reply
No replies to this topic

#1 guillaumeMichael

guillaumeMichael

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 16 May 2019 - 02:52 PM

I'm creating a C# code to retrieve stream from your platform and I having the following error:

 

InvalidOperationException: No MediaTypeFormatter is available to read an object of type 'Object' from content with media type 'application/vnd.altairsc.v2+json'.

 

This code works for any other WebApi I request but not from your platform, can you help me ?

            HttpClient httpClient;

            httpClient = new HttpClient();
            httpClient.BaseAddress = new Uri("https://api.iotagora.net/");
            httpClient.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            httpClient.DefaultRequestHeaders.Add("carriots.apikey",
                "xxx");

            var responseMessage = await httpClient.GetAsync("streams");
            responseMessage.EnsureSuccessStatusCode();
            var obj = await responseMessage.Content.ReadAsAsync<object>();

I already tried to add this but doesn't work

 

 httpClient.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/vnd.altairsc.v2+json"));





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users