getting 'Request caused exception: Unexpected character encountered while parsing value: {. Path '', line 1, position 1.' for POST REST API call in .net


#1

Hi

I have code that can generates JWT token and call rest API get methods with no problem


                String BaseUri = “https://api.zoom.us/”;
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(BaseUri);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(“application/json”));
                client.DefaultRequestHeaders.Add(“Authorization”, "Bearer " + GenerateToken());

                HttpResponseMessage response = await client.GetAsync(“v2/users/userId/meetings”);
                var responseString = await response.Content.ReadAsStringAsync();


However, I am getting error in title for a post method i.e meeting creation


              String BaseUri = “https://api.zoom.us/”;
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(BaseUri);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(“application/json”));
                client.DefaultRequestHeaders.Add(“Authorization”, "Bearer " + GenerateToken());

                JObject meeting = new JObject(
                        new JProperty(“topic”, “Username”),
                        new JProperty(“start_time”, “2018-01-11T23:00:00”),
                 );

                var httpContent = new StringContent(meeting.ToString(), Encoding.UTF8, “application/json”);

                var postTask = await client.PostAsJsonAsync(“https://api.zoom.us/v2/users/userId/meetings”, httpContent);

 


#2

Hi Baris, can you please provide the error message?