- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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}");
}
Solved! Go to Solution.