Str apiUrl; System.Exception ex; ISharePointProxy proxy; String255 fNewFolder = _projTable.ProjId; String255 fServer = 'https://test.sharepoint.com/SharePointIntegrationD365FO'; String255 fRootFolder = 'Documents'; System.UriBuilder builder = new System.UriBuilder(fServer); str hostName = builder.Host; str siteName = fRootFolder; str externalId = xUserInfo::getCurrentUserExternalId(); boolean validConnection = false; proxy = SharePointHelper::CreateProxy(hostName, '/', externalId); if(proxy) { if(SharePointHelper::VerifyAuthentication(proxy)) { validConnection = true; info(strfmt('@ApplicationFoundation:SPServerCommunicationSuccess', hostName)); } else { info(strfmt('@ApplicationFoundation:SPServerUserNotAuthorized', hostName)); } } else { info(strfmt('@ApplicationFoundation:SPSelectionDlg_ErrorNoProxy', hostName)); } if(validConnection) { apiUrl = strFmt(/%1/_api/web/lists/getbytitle('%2')/folders/add('%3')/, fServer, fRootFolder, fNewFolder); /apiUrl = strFmt(/%1/_api/web/GetFolderByServerRelativeUrl('%2')/Folders/add('%3')/,fServer, fRootFolder, fNewFolder); /apiUrl = strFmt(/%1/_api/web/folders/add('%3')/,fServer, fNewFolder); try { str token = proxy.AccessToken; System.Net.WebHeaderCollection httpHeader = new System.Net.WebHeaderCollection(); httpHeader.Add(/Authorization/, 'Bearer ' + token); HttpWebRequest request = System.Net.WebRequest::Create(apiUrl); request.set_Headers(httpHeader); request.set_ContentLength(0); request.set_Method(/POST/); request.set_ContentType(/application/json;odata=verbose/); System.Net.HttpWebResponse response = request.GetResponse(); int statusCode = response.get_StatusCode(); info(strFmt(/HTTP status code: %1/, statusCode)); } catch { //exception ex = CLRInterop::getLastException().GetBaseException(); error(ex.get_Message()); } }