sharepoint-2010dynamics-crm-2011document-management

CRM 2011 and SharePoint using document management from CRM SDK


I need to test the CRM 2011 and SharePoint document management performance. So I hooked up CRM and SharePoint together using Document list component.

And now I need to upload a document into SharePoint (not attachment) using CRM SDK.

Is there any solutions, or even a little piece of code which uploads a document into a SharePoint document list?

Sultan


Solution

  • What I do is:

    Create the Sharepoint Document Location (related to the SP Site) with a relative url (via CRM SDK).

    Turn the file into a byte array and then I feed that to my HTTP PUT method to get the file up to sharepoint:

    private NetworkCredential loginCredentials = new NetworkCredential(login, password, domain);
    
    WebClient wc = new WebClient();
    wc.Credentials = loginCredentials;
    wc.UploadData(destinationUrl, "PUT", fileData);
    

    destinationUrl is where I want it to go (http:\\spite\accounts\RyanonRails\examplefile.txt), fileDate is a byte[]. Make sure the user you're using has Full Control (so it can upload).

    This method works great when you receive a report from SSRS.

    Sidenote: When I tried to use the actual sharepoint 2010 copy.asmx web service it failed to work cross domain.