Hi,
I am using MS CRM 365 online, working on the integration MS CRM with SharePoint.
I am able to create the folder in the sharepoint using custom action, is there a way we can check if the folder is already created in the sharepoint ?
1. is it necessry to create the DocumentLocation folder in CRM first before uploading the file to share point ?(Automatic doucmentLocation creation is enabled in CRM during SharePoint integration)
I tested directly creating the folder in sharepoint through code and uploading the file manually, it seems to be working fine.
currently I am using below code to create the folder : This code is working without any issue. I need something similar to check if the folder is already created in the Sharepoint.
public void CreateFolder(string siteUrl, string relativePath)
{
if (siteUrl != _siteUrl)
{
_siteUrl = siteUrl;
Uri spSite = new Uri(siteUrl);
_spo = SpoAuthUtility.Create(spSite, _username, WebUtility.HtmlEncode(_password), false);
}
string odataQuery = "_api/web/folders";
byte[] content = ASCIIEncoding.ASCII.GetBytes(@"{ '__metadata': { 'type': 'SP.Folder' }, 'ServerRelativeUrl': '" + relativePath + "'}");
string digest = _spo.GetRequestDigest();
Uri url = new Uri(String.Format("{0}/{1}", _spo.SiteUrl, odataQuery));
// Set X-RequestDigest
var webRequest = (HttpWebRequest)HttpWebRequest.Create(url);
webRequest.Headers.Add("X-RequestDigest", digest);
// Send a json odata request to SPO rest services to fetch all list items for the list.
byte[] result = HttpHelper.SendODataJsonRequest(
url,
"POST", // reading data from SP through the rest api usually uses the GET verb
content,
webRequest,
_spo // pass in the helper object that allows us to make authenticated calls to SPO rest services
);
string response = Encoding.UTF8.GetString(result, 0, result.Length);
}
*This post is locked for comments