Trying to create subfolders in a project via Python

Hi there,

I created a new developer token with all permissions and when I try to create a subfolder via Python I get the following error:
Details: {“code”:403,“message”:“Forbidden”,“errors”:[{“code”:403,“status”:403,“title”:“Forbidden”,“detail”:“You do not have permission to access that resource”}]}

Even though my token has all permissions, can you tell me why?

Python code extract:

def createFolder(name, parent_id):

        folderInfo = {
            "name": name,
            "type": "folder",
            "parent_id": parent_id
        }

        response = requests.post(
            "https://api.frame.io/v2/assets",
            headers=headers,
            json = folderInfo
        )

        if response.status_code in [200,201]:
            return response.json()["id"]
        else:
            print(f"Failed to create folder '{name}':", response.status_code)
            print("Details:", response.text)
            return None
    
    subFolder1_id = createFolder(
        "Subfolder", 
        root_asset_id
        )

I suspect maybe the post url is incorrect but I can’t get any further at the moment.

Cheers,
Peek

I figured it out after some experimenting, it turns out my submission URL needed some tweaking:
“f"https://api.frame.io/v2/assets/{parent_id}/children”"

That one properly creates subfolders and nested folders.

1 Like

Glad you were able to figure it out!

Let us know if you have more questions.