0
votes

i am trying to call the Zoom Api for Access token. It work Perfectly fine when i am trying to post with postman . but from code it does not respond

ZoomApiLink_StepNo2

below are the following details

 public static async Task<String> PostTogetToken<T>(string requestUrl, string client_Secretkey) {
            ZoomToken hello = new ZoomToken();

            var EncodedURl = ApiService.Base64Encode(client_Secretkey);
            using (var _httpClient = new HttpClient()) {

                if (!string.IsNullOrEmpty(requestUrl))
                    _httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Basic " + EncodedURl);

                var httpContent = new StringContent("", System.Text.Encoding.UTF8, "application/x-www-form-urlencoded");

                var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, new Uri(requestUrl)) {
                    Version = HttpVersion.Version11,
                    Content = httpContent
                };

                using (var response = await _httpClient.SendAsync(httpRequestMessage)) {
                    if (response.IsSuccessStatusCode) {
                        response.EnsureSuccessStatusCode();
                        return await response.Content.ReadAsStringAsync();
                    } else {
                        return await response.Content.ReadAsStringAsync();
                    }
                }
            }
        }
1
Are you calling Result or Wait further up your call stack?Stephen Cleary
@StephenCleary ResultSumit Singh

1 Answers

0
votes

You're seeing a common deadlock problem because code further up the stack is using Result, blocking on asynchronous code.

To fix, change the Result to await and use async all the way.