I'm trying to create a webhook for the dm.verison.modified
event, but want to filter it down to events that are for file extension .rvt
and the storm:process-state
equal to PROCESSING_COMPLETE
. This way I only receive callback from webhook when a Revit file is done processing on ACC. Ref the blog post that shows how we can track process state of a file using Webhook responses: https://aps.autodesk.com/blog/parse-webhook-response-modified-event-different-file-types.
I see that Webhooks API supports callback filtering with multiple filters:https://aps.autodesk.com/en/docs/webhooks/v1/developers_guide/callback-filtering/
But I am unable to create a webhook with multiple filters. I get a 400 Bad Request when my request contains an array of filters. Here is my request:
POST https://developer.api.autodesk.com/webhooks/v1/systems/data/events/dm.version.added/hooks
Body:
{
"callbackUrl": "https://my-app.com/webhooks/callback/version-modified",
"scope": {
"folder": "urn:adsk.wipprod:fs.folder:xxxxxxx"
},
"filter": ["$[?(@.ext=='rvt')]", "$[?(@.custom-metadata.storm:process-state=='NEEDS_PROCESSING')]"]
}
The response I get from Webhook API:
{
"id": "866d6804-5c42-4c26-bf54-4e72be2bff7a",
"status": 400,
"code": "VALIDATION_ERROR",
"detail": [
"Payload is not valid for serialization"
]
}
I have tried multiple variations of passing the whole array of filters as a single string literal, like so: "[$[?(@.ext=='rvt')], $[?(@.custom-metadata.storm:process-state=='NEEDS_PROCESSING')]]"
.
But I still get a 400 Bad Request, with the error " Invalid filter: [$[?(@.ext=='rvt')], $[?(@.custom-metadata.storm:process-state=='NEEDS_PROCESSING')]]"
The Callback Filtering documentation you provided the link to refers to the JsonPath format that the filter
requires.
The readme there says:
Based on that I could come up with this that was accepted when creating the webhook:
$[?(@.ext=='rvt' || @.custom-metadata.storm:process-state=='NEEDS_PROCESSING')]
Update:
I was told that this should work (notice there is no space after the comma, otherwise it won't be accepted):
"filter": "[\"$[?(@.ext=='rvt')]\",\"$[?(@.custom-metadata.storm:process-state=='NEEDS_PROCESSING')]\"]",