cancel
Showing results for 
Search instead for 
Did you mean: 

Using bulk import

Taaviansper
Confirmed Champ
Confirmed Champ

I have some questions regarding bulk import

https://docs.alfresco.com/content-services/6.1/admin/import-transfer/#import-tool-fieldsvals

A former colleague used this to import data. 

curl 'https://'${ALFRESCOHOST}'/alfresco/service/bulkfsimport/initiate' \
          -H 'Authorization: Basic '${PWDHASH}'' \
          -L POST --url "https://'${ALFRESCOHOST}'/alfresco/s/bulkfsimport/initiate" --data "targetNodeRef=workspace://SpacesStore/${USERDIRUUID}&sourceDirectory=${CONTAINERPATH}/${OLDDHSNAME}_k&existingFileMode.skip"

I've been trying to do a similar thing on python, but how do I exactly approach this? It seems to me that 

I've made something like this. 

def bulk_import(row, options, b64encoded, data):
      url = 'https://' + options['servername'] + '/alfresco/service/bulkfsimport/initiate'
      headers={"Authorization": f'Basic {b64encoded}'}
      response = requests.post(url=url, data=data)
      return response

data = f'targetNodeRef=workspace://SpacesStore/{personDirectoryId}&sourceDirectory={row["system_location"]}&existingFileMode.skip'

But it gives me an error. 401.

1 ACCEPTED ANSWER

Taaviansper
Confirmed Champ
Confirmed Champ
data = {'targetNodeRef': f'workspace://SpacesStore/{create_folder_entry["id"]}', 'sourceDirectory' : f'{row["system_location"]}', 'existingFileMode.skip': ""}

 headers={"Authorization": f'Basic {b64encoded}', 'Content-Type': 'application/x-www-form-urlencoded'}

This worked! 

View answer in original post

4 REPLIES 4

Taaviansper
Confirmed Champ
Confirmed Champ

First problem solved, I forgot to add headers to request. 

Second problem still active: Request sent by the client was syntactically incorrect. 

03140066 Error: neither parameter 'targetNodeRef' nor parameter 'targetPath' was provided, but at least one is required !

Taaviansper
Confirmed Champ
Confirmed Champ

I got it to work using postman, well. The only thing missing is that bulkimport can't see my filesystem so i have to copy over all the files to the same docker container where the bulk import thingy sits and make the exact same system_location there. 

Now i need to convert this postman thingy to python.image

EddieMay
World-Class Innovator
World-Class Innovator

Hi @Taaviansper 

Great that you got a solution & thanks for updating with the solution - really useful to other users.

Cheers,

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!

Taaviansper
Confirmed Champ
Confirmed Champ
data = {'targetNodeRef': f'workspace://SpacesStore/{create_folder_entry["id"]}', 'sourceDirectory' : f'{row["system_location"]}', 'existingFileMode.skip': ""}

 headers={"Authorization": f'Basic {b64encoded}', 'Content-Type': 'application/x-www-form-urlencoded'}

This worked!