I’m trying to connect to the rest API by using python in Dynamo-Revit. I created an acces-token but it seems to be invalid although i should have the right authorisation. The script that i’m using is as shown below. Currently my role is ‘Contributer’ to the workspace. The http error-code i get is 403 “Your token is not valid”. Is this maybe because i should encrypt the token first can it be something else? Thanks in advance for helping me!
With that token police message out of the way. You will likely need to add minimum pta scopes for stream:read but also user:read or user-profile:read I forget which.
Sorry I should have spotted before - that endpoint is expecting a POST request that also includes a list of objects to get.
# Replace with your actual token and ensure no leading/trailing spaces
TOKEN = "your_actual_token_here"
project_id = "6a87e55c77" # Replace with your project ID
header = {
'Authorization': f'Bearer {TOKEN}',
'Accept': 'application/json'
}
url_get = f"https://app.speckle.systems/api/getobjects/{project_id}"
# Replace with actual object IDs you want to request
body = {
"objects": ["objectId1", "objectId2", "objectId3"] # Example IDs
}
response = requests.post(url=url_get, headers=header, json=body)
@jonathon and @iainsproat, I seem to get a little bit further. With the code down below i got a valid “200” status_code. The issue now is that i now get an empty list where i was expecting data.
header={
"Authorization": f"Bearer {Token}",
"Accept": "application/json",
"Content-Type": "application/json"
}
body = {
'objects': ['"cf02d5566caa6c38c3e2a7d9154168f4"']
}
url_get=f"https://app.speckle.systems/api/getobjects/{IN[0]}"
with requests.post(url=url_get,headers=header,json=body,stream=True) as r:
OUT=r