teference / zoho-dotnet

Zoho API .NET SDK
MIT License
7 stars 11 forks source link

No response #21

Closed CodersExpo closed 5 years ago

CodersExpo commented 5 years ago

I'm calling await subscription.Customers.GetAsync(customerId); and I get nothing back. No error. Nothing.

I wrote my own just to validate and it works fine. ` public string ExecutePostRequest(byte[] reqData, string resource) { string zohoResponse = string.Empty;

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
            string.Format(CultureInfo.InvariantCulture, "{0}/{1}", urlAPI, resource));

        request.Headers.Add(
            string.Format(CultureInfo.InvariantCulture, "Authorization: Zoho-authtoken {0}", authToken));
        request.Headers.Add(
            string.Format(CultureInfo.InvariantCulture, "X-com-zoho-subscriptions-organizationid: {0}", orgId));

        request.ContentType = "Content-Type: application/json;charset=UTF-8";
        request.ContentLength = reqData.Length;
        request.Method = "POST";
        request.UseDefaultCredentials = true;
        request.PreAuthenticate = true;

        using (var dataStream = request.GetRequestStream())
        {
            dataStream.Write(reqData, 0, reqData.Length);

            dataStream.Close();
        }

        using (var response = request.GetResponse())
        {
            string statusDescription = ((HttpWebResponse)response).StatusDescription;
            //Check if statusDescription is ok or success
            using (var dataStream = response.GetResponseStream())
            {
                var streamReader = new StreamReader(dataStream);
                zohoResponse = streamReader.ReadToEnd();

                dataStream.Close();
            }

            response.Close();
        }

        return zohoResponse;
    }`

Question, am I missing a dependency or something?? If there was an error does this bubble up?

CodersExpo commented 5 years ago

Ok I'm a fool. I did not set await! Arrg.

So, for anyone reading be sure to do something like... var zohoCustomer = await zohoTransactions.GetZohoCustomer(customerId);

...on an async method. ie:

public async Task<string> GetResellerById(string customerId)

I wasn't waiting for a response! Oh my...

CodersExpo commented 5 years ago

Nice api thanks for this!