Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

3 legged auth - cannot create folder forbidden

kevin.bza
Enthusiast

3 legged auth - cannot create folder forbidden

kevin.bza
Enthusiast
Enthusiast

Greetings,

Scopes: data:read data:write data:create data:search bucket:create bucket:read code:all bucket:update

with 3 legged auth. Result is forbidden. Code below - what did I miss?

I am trying to use httpclient instead of the nuget packages. Dev with nuget packages is working correctly, can create folders that way, but I need to use httpclient.

Thx for reading,

K.

 

 

        var url = $"https://developer.api.autodesk.com/data/v1/projects/{projectID}/folders";

        var folderData = new
        {
            jsonapi = new { version = "1.0" },
            data = new
            {
                type = "folders",
                attributes = new
                {
                    name = "AgainNewFolderAgain",
                    extension = new
                    {
                        type = "folders:autodesk.core:Folder",
                        version = "1.0"
                    }
                }
                ,
                relationships = new
                {
                    parent = new
                    {
                        data = new
                        {
                            type = "folders",
                            id = folderId
                        }
                    }
                }
            }
        };

        var client = new HttpClient();
        client.DefaultRequestHeaders.Clear();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken);
        var response = await client.PostAsJsonAsync(url, folderData);
        if (response.IsSuccessStatusCode)
        {
            Console.WriteLine($"Folder created successfully.");
        }
        else
        {
            Console.WriteLine($"Failed to create folder. Status code: {response.StatusCode}");
        }

 

 

 

 

 

0 Likes
Reply
Accepted solutions (1)
662 Views
1 Reply
Reply (1)

kevin.bza
Enthusiast
Enthusiast
Accepted solution

folder type! Even though this is an ACC platform Project - the folder type in JSON is: folders:autodesk.bim360:Folder

0 Likes