Hi
so i called a token url (authorization) using postman and i got the result correctly where i filled client Id, client secret and client credentials.
However when i did this by code I'm getting an error at this line " System.IO.Stream dataStream = request.GetRequestStream()" as you can see below
System.Text.Encoding encoding = System.Text.Encoding::UTF8;
Password clientSecret = cryptoblob2str(WinAPIServer::cryptUnProtectData(clientSecret1)); //clientSecret1 is defined
System.Byte[] bytes = encoding.GetBytes(ClientId ":" clientSecret); //client id is defined
System.String base64 = System.Convert::ToBase64String(bytes);
System.Net.WebHeaderCollection header = new System.Net.WebHeaderCollection();
System.String headerKey = "Authorization";
System.String headerValue = "Basic " base64;
header.Add(headerKey,headerValue);
System.Net.WebRequest request = System.Net.WebRequest::Create(tokenURL);//token url is defined
request.Method = "POST";
request.set_Headers(header);
request.set_ContentType("application/x-www-form-urlencoded");
str bodyKeyValue = "grant_type=client_credentials";
System.Byte[] byteArray = encoding.GetBytes(bodyKeyValue);
request.set_ContentLength(byteArray.get_Length());
using(System.IO.Stream dataStream = request.GetRequestStream()) //Error is here
{
dataStream.Write(byteArray, 0, byteArray.get_Length());
}
Any idea what i'm doing wrong