Search code examples
python-requestsautodesk-forgepayloadautodesk-bim360

Autodesk forge Webhook API, Error 400 400, VALIDATION_ERROR


using autodesk forge API, I am trying to create a webhook over folder using the following information; unfortunately, I am receiving the following response:

{
   "id":"xxxx-xxxx-xxx-xxxxx",
   "status":400,
   "code":"VALIDATION_ERROR",
   "detail":["Payload is not valid for serialization"]
}

URL: https://developer.api.autodesk.com/webhooks/v1/systems/data/events/dm.folder.added/hooks (for specific folder added event) or: https://developer.api.autodesk.com/webhooks/v1/systems/data/hooks (for all events). Both are returning the same error

Header:

{
"Content-Type":"application/json",
   "Authorization":"<MY_TOKEN>",
   "x-ads-region":"US"
}

Data:

{
   "callbackUrl":"<MY_DOMAIN>:<MY_PORT>/callback",
   "scope":{
      "folder":"urn:adsk.wipprod:fs.folder:co.xxxxxxxxxxxx-xxxxx"
   }
}

Troubleshooting:

  • I've tried different folders, root and non-root. I can access all the folders i tried using the api
  • I am sure that my account is US region
  • I've tried to add hubId and/or projectId, but I received the same error
  • <MY_DOMAIN>:<MY_PORT>/callback is configured and working fine
  • Headers and Data are serializing and de-serializing normally using json loads & dumps

Any suggestion/help?


Solution

  • Answering myself :)

    I've discovered that my issue is not related to Forge API, it's a general one related to python Requests. The payload (data) of Requests cannot be nested dictionary, only 1 level dictionary is accepted, nested ones will fail. the solution is to stringify the dict (json.dumps) and use that string as request payload.