POST Error on Accesstoken

I’m getting errors making the POST request with the autorization code to get the access token. I tried different ways but I’m getting always an ‘Unexpected sending error’. This is the c# code of my last try. What is wrong?

			var request = HttpWebRequest.Create("");
			request.ContentType = "application/x-www-form-urlencoded";
			request.Method = "POST";

			string base64dat = Base64Encode("XXXXXXXXXXXX" + ":" + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
			request.Headers.Add("Authorization", "Basic " + base64dat);

			string postData = "grant_type=authorization_code&code=" + code + "&redirect_uri=" + "";

			var data = Encoding.ASCII.GetBytes(postData);
			request.ContentLength = data.Length;

			using (var stream = request.GetRequestStream())
				stream.Write(data, 0, data.Length);

			var response = (HttpWebResponse)request.GetResponse();
			var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

Hey @jesuspampin,

Can you try removing request.ContentType = "application/x-www-form-urlencoded"; ?

Let me know if that fixes it.


Thanks, I found on internet the solution. I put the parameters on the end of the url and add this line to enable all protocols.
ServicePointManager.SecurityProtocol =
| SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12;

With this now I get the token and I can create the meeting. Thanks!!!.

1 Like

Happy to hear you figured it out! :slight_smile: