cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing bulk import utility externally

srowsell
Champ in-the-making
Champ in-the-making
I'm trying to run the bulk file import utility using a C# web page.  This is a POST web script (alfresco/service/bulkfsimport/initiate), so I can't put the various parameters into the URL.  Anyway my code looks something like this:

<blockcode>using (var wb = new WebClient())
        {
           
            var data = new System.Collections.Specialized.NameValueCollection();
            //data["alf_ticket"] = ticket;
            data["sourceDirectory"] = @"C:\Temp\Statements";
            data["targetPath"] = "/Company Home";
            //data["targetPath"] = "/Company Home/Sites/general/documentLibrary/Statements";
            data["replaceExisting"] = "true";
            data["disableRules"] = "true";
            data["batchSize"] = "50";
            data["numThreads"] = "4";
            string url = "http://localhost:8080/alfresco/service/bulkfsimport/initiate?alf_ticket='+ticket;
            //string url = "http://localhost:8080/alfresco/service/bulkfsimport/initiate";
            var response = wb.UploadValues(url, "POST", data);
        }</blockcode>

I've tried including the ticket both as part of the POST object and as part of the URL.  Every time I try this I get a 401 authentication error, and yes, I'm sure that I'm using good credentials.

Any thoughts?

3 REPLIES 3

billydoe
Champ in-the-making
Champ in-the-making
//I encounter the same issue. It is resolved after adding following credential in webclient.
CredentialCache cc = new CredentialCache();
cc.Add(new Uri("http://localhost:80/alfresco"), "Basic", new NetworkCredential("username", "password"));
wb.Credentials = cc;

//use the following URL
string url = "http://localhost:80/alfresco/service/bulkfsimport/initiate";
  var response = wb.UploadValues(url, "POST", data);

//Minor correction on checkbox parameters
data["replaceExisting"] = "replaceExisting";
data["disableRules"] = "disableRules";

srowsell
Champ in-the-making
Champ in-the-making
Well, I'm not trying to do things like this anymore, but if I were I'd be glad to have this advice.  Thanks.

billydoe
Champ in-the-making
Champ in-the-making
Welcome. Hope it will benefit for others