04-14-2021 07:57 AM
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.
04-14-2021 08:59 AM
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!
04-14-2021 07:59 AM
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 !
04-14-2021 08:55 AM
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.
04-15-2021 09:38 AM
Hi @Taaviansper
Great that you got a solution & thanks for updating with the solution - really useful to other users.
Cheers,
04-14-2021 08:59 AM
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!
Explore our Alfresco products with the links below. Use labels to filter content by product module.