Avatar of ITsolutionWizard
Flag for United States of America

asked on 

Zoom's API call return error message

The codes below are consuming zoom api and it works, however when issuccessful == false,
I want to know why and hope to return an error message that came from Zoom API.
Do you know how to capture error message?

public Zoom CreateRegistrant(Zoom z, Zoom.Registrant r, Zoom.Webinar w)
            #region assign parameters into local parameters
            string htmlTemplate = string.Empty;
            Int64 webinarID = Convert.ToInt64(w.id);
            string first_name = r.first_name;
            string last_name = r.last_name;
            string email = r.email;
            string phone = r.phone;            
            dynamic obj = new
                email = email,
                first_name = first_name,
                last_name = last_name,
                phone = phone
            string jsonString = JsonConvert.SerializeObject(obj, Formatting.Indented);
            #region declare bridge
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            var client = new RestSharp.RestClient("https://api.zoom.us/v2/webinars/" + webinarID + "/registrants");
            var request = new RestRequest(Method.POST);
            #region declare request API
            request.AddHeader("content-type", "application/json");
            request.AddHeader("authorization", z.authorization);
            request.AddParameter("application/json", jsonString, ParameterType.RequestBody);
            IRestResponse responseClass = client.Execute<Zoom.Webinar>(request);
            #region get response
            if (responseClass.IsSuccessful)
                var t1 = JsonConvert.DeserializeObject<Zoom.Webinar>(responseClass.Content);               
                z.isSuccessful = responseClass.IsSuccessful;
                w.join_url = t1.join_url;
                w.start_time = t1.start_time;
                w.topic = t1.topic;
                w.registrant_id = t1.registrant_id;
                z.isSuccessful = false;
            #region output
            return z;

Open in new window

ASP.NETC#Web Services

Avatar of undefined
Last Comment

8/22/2022 - Mon