I am attempting to move an item to a specific folder (using Python API, NOT Juypter). I don't see anything in the API to check if a folder exists. So according to the API:
move(folder, owner=None)¶
Moves this item to the folder with the given name.
Argument | Description |
folder | Required string. The name of the folder to move the item to. Use ‘/’ for the root folder. For other folders, pass in the folder name as a string, or a dictionary containing the folder ID, such as the dictionary obtained from the folders property. |
owner | Optional string or Owner object. The name of the user to move to. |
Returns: | A json object like the following: {“success”: true | false,
|
---|
I'm trying to figure out how to capture the return object. I've wrapped it in a Try/Catch but that doesn't seem to work. It always gets to the next line but I get the console message, Folder not found for given owner.
If I do:
objMoved = myItem.move(folder="whatever")
objMoved is always None
What's the "best practice" way to get the results?
Solved! Go to Solution.
The following code solves my issue:
objMoved = newmap.move(folder=configStore.folder) #folder not found for given owner message if it doesnt move it. print(objMoved) if (objMoved is None) or \ (objMoved is not None and 'success' in objMoved and not objMoved['success']): print("we flunked moving the object") newmap.delete(force=False, dry_run=False) sys.exit( "ERROR: Unable to move the item with ItemID {0} to the folder, {1}. ".format( id, configStore.folder))
The following code solves my issue:
objMoved = newmap.move(folder=configStore.folder) #folder not found for given owner message if it doesnt move it. print(objMoved) if (objMoved is None) or \ (objMoved is not None and 'success' in objMoved and not objMoved['success']): print("we flunked moving the object") newmap.delete(force=False, dry_run=False) sys.exit( "ERROR: Unable to move the item with ItemID {0} to the folder, {1}. ".format( id, configStore.folder))