OAuthReq := STRSUBSTNO(OAuthReqTxt,recILSSetup."API Conf Client ID",recILSSetup."API Conf Client Secret",recILSSetup."API Resource ID"); sb := sb.StringBuilder(); sb.Append(OAuthReq); UTFEncoding := UTFEncoding.UTF8Encoding; JsonLength := UTFEncoding.GetBytes(sb.ToString).Length; HttpWebRequest := HttpWebRequest.Create(STRSUBSTNO(recILSSetup."OAUTH URL",recILSSetup."Tenant ID")); HttpWebRequest.Timeout := 30000; HttpWebRequest.Method := 'POST'; HttpWebRequest.ContentType:= 'application/form-urlencoded'; //'multipart/form-data'; //'application/x-www-form-urlencoded'; ServicePointManager.SecurityProtocol(SecurityProtocol.Tls12); //Need to define encryption to prevent Web Service from rejecting request ResponseStream := HttpWebRequest.GetRequestStream; ResponseStream.Write(UTFEncoding.GetBytes(sb.ToString),0,JsonLength); ResponseStream.Close; HttpWebResponse := HttpWebRequest.GetResponse; //ALWAYS FAILS HERE
Answers