autodesk forge – I’m trying to get my old buckets, but keeps giving me a 400 error
I am trying to find a bucket that i used to upload a few revit files, so that i can download them.
The files are there, I know, because I can see them in the viewer.
I am using my credentials, getting my access_token.
But when I create a request like the one below
bucket_url="https://developer.api.autodesk.com/oss/v2/buckets"
headers = {
'Authorization': f'Bearer {access_token}',
'Content-Type': 'text/json'
}
bucket_response = requests.post(bucket_url, headers=headers)
I get the message :
bucketss_list_response
{‘reason’: ‘Unable to parse JSON’}
What am I doing wrong?!
this is how I am getting my access_token:
auth_data = {
'grant_type': 'client_credentials',
'scope': 'data:read data:write bucket:create bucket:read'
}
newBasicAuth = FORGE_CLIENT_ID+":"+FORGE_CLIENT_SECRET
encoded = base64.b64encode(newBasicAuth.encode())
headers = {"Content-Type": "application/x-www-form-urlencoded"}
headers["Authorization"]="Basic " + encoded.decode("utf-8")
auth_response = requests.post(auth_url, data=auth_data, headers=headers)
access_token = auth_response.json().get('access_token')
I tried:
curl -X GET "https://developer.api.autodesk.com/oss/v2/buckets/YOUR_BUCKET_KEY/objects" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
And was expecting:
{
"items": [
{
"objectKey": "model_1.rvt",
"size": 1234567,
"contentType": "application/octet-stream"
},
{
"objectKey": "model_2.rvt",
"size": 2345678,
"contentType": "application/octet-stream"
}
]
}
Read more here: Source link