Reputation: 1
I have tried but dont know how to read data from API response. I was able to get 200 status code but I can't figure out how to get actualdata. I am trying to get data from Withings API (http://developer.withings.com/oauth2/#tag/measure%2Fpaths%2Fhttps%3A~1~1wbsapi.withings.net~1measure%3Faction%3Dgetmeas%2Fget)
Below response i got:
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET, POST, OPTIONS Access-Control-Allow-Headers: Content-Type, * Date: Mon, 10 Jun 2019 11:51:03 GMT Server: Apache Content-Length: 65 Content-Type: text/plain; charset=UTF-8
The following is my code:
string accessToken = "my_accessToken";
HttpClient client = new HttpClient();
var url = "https://wbsapi.withings.net/measure?action=getmeas&meastype=1&category=1&startdate=737060&enddate=737179&offset=0";
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken);
var response = await client.GetAsync(url);
string content1 = await response.Content.ReadAsStringAsync();
string content2 = response.Content.ReadAsStringAsync().Result;
Above i have added link for withings API. Is anyone guide how to get data from response body.
Upvotes: 0
Views: 997
Reputation: 1
Problem has been resolved now. The problem was API does not support TLS1 and as i set security protocol to Tls12 it works. Below is code which i used.
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
Thanks to all.
Upvotes: 0