You need to sign in to do that
Don't have an account?
Nitin Muthyala
However if I use the same API to upload to a sync folder I dont have any issues, it works.
Also if i upload a file from the browser it works, so defiantly I have the permission, I have double checked in the permission settings as well I have all permissions to upload a file.
Doesn anyone know whats the possible reason ?
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY when adding file to a content library using REST API
Im tring to replicate some of the Content Library features in my custom app so Im usgint the REST API to achive this. I successfully managed to add Library features features like
View Files in Folder (Inside a library)
Download a File
Rename File
But when I try to Upload a file it says
[{"errorCode":"INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY","message":"Cannot move a file into a folder you do not have access to."}]Im sending a post request to https://ap1.salesforce.com/services/data/v40.0/connect/folders/07H900000008W0MEAU/items
However if I use the same API to upload to a sync folder I dont have any issues, it works.
Also if i upload a file from the browser it works, so defiantly I have the permission, I have double checked in the permission settings as well I have all permissions to upload a file.
Doesn anyone know whats the possible reason ?
The problem is that POST through Chatter REST isn't supported for Libraries. I know the error message isn't clear.
I'm not sure how to achieve what you want through REST, but using SOAP, you can upload a file to a library by inserting a ContentVersion and setting the FirstPublishLocationId to the libraryId. Once it's in the library, using SOAP you could update the ContentFolderMember to move it the folder you want, or I think REST would work to move it to a new folder as well (I'm not certain).
One possibily I haven't tried to use ONLY rest would involve:
- Uploading the file to the user (not in a library) so it will be private to the user
- Using the File Shares (https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_files_shares.htm) endpoint to share the file with the library you want
- Move the file to the folder you want
I understand the current options are convoluted, and I will log a user story to address the REST api for libraries.