API Specified folder '' does not exist


#1

Hello,

I’m using API to upload assets and create folders. The problem is, that before I upload an asset using API, I create folder structure. It looks like that when I call setfolder API call, code is executed but new folder isn’t created instantly on the system, so when the upload asset code part is executed, asset can’t be uploaded because folder doesn’t exist yet.

Also when I’m uploading assets in bulk I first check if an asset with the same name already exists in the folder and if it does new file is renamed before upload. But if I upload files one after the other the problem is that the file before the current file hasn’t been created on the system yet so again I can’t check if the filename already exists.

I hope you understand my problem because it is complex and I don’t know exactly how to explain it.

Thank you!

Best wishes,
Marko


#2

Not really complex, you just need to time it properly.

First off, you cannot upload files without providing a folderid. Hence you need to create a folder first and then pass that ID to the file upload. Simply create the folder first and wait for the completion.

Secondly, your file upload has the same issue. As explained multiple times on this forum, the API will return you the asset id immediately, though that doesn’t mean the file is in the system as it might take a longer time to create renditions, apply workflow, and so forth.

You can also enable the duplicate file check which will not add the file and then you can rename it locally and re-upload. Though, file check is done with the md5 hash, so just renaming the file won’t do it.

Hope this helps.


#3

Hello,

thank you for your answer. I know that the problem is in time of completion, but how can I check if the folder or file has already been created so I can continue with folder creation and file upload?

How can I get a folder id or file id of newly created file/folder? I don’t see this information in JSON response. If I can get an ID I can wait until the file/folder wirh this ID is completed and then continue with folder creation or file upload…

Thank you!

Best wishes,
Marko


#4

Hello,

sorry, now I see that id is in the JSON response. So I should create a loop and check if asset id or folder id exists and after id does I should continue with the upload or is there a better way?

Thank you!