Hi Community ,
when setting up HttpWebRequest ContentLength as shown in the code below, i found that there's no ContentLength attribute for HttpWebRequest. Add to that i had an error message to initialize the StatusCode before using it. AnyOne can help please ?
GetToken() Token : Text SharepointSetup_L.GET(USERID); granttype:=SharepointSetup_L."Grant Type"; clientid:=SharepointSetup_L.Client_Id '@' SharepointSetup_L.Tenant; ClientSecret:=SharepointSetup_L."Client Secret"; resources := SharepointSetup_L.Resources '/' SharepointSetup_L.Domain '.sharepoint.com@' SharepointSetup_L.Tenant; tenant := SharepointSetup_L.Tenant; RequestURI_L := 'https://accounts.accesscontrol.windows.net/' tenant '/tokens/oAuth/2'; PostData :='grant_type=' TypeHelper.UrlEncode(granttype) '&client_id=' TypeHelper.UrlEncode(clientid) '&client_secret=' TypeHelper.UrlEncode(ClientSecret) '&resource=' TypeHelper.UrlEncode(resources); HttpWebRequest_L.Initialize(RequestURI_L); HttpWebRequest_L.DisableUI; HttpWebRequest_L.SetTimeout(300000); HttpWebRequest_L.SetMethod('POST'); HttpWebRequest_L.SetContentType('application/x-www-form-urlencoded'); // HttpWebRequest_L.ContentLength := RequestString.Length; SetRequestStream(HttpWebRequest, PostData); HttpWebRequest_L.GetResponseStream(InStr); HttpWebResponse.StatusCode := HttpWebResponse.StatusCode; IF FORMAT(HttpWebResponse.StatusCode) = 'OK' THEN BEGIN Streamreader := Streamreader.StreamReader(InStr); JSonString := Streamreader.ReadToEnd; END