How to use webhooks for translations

Michał_Wójcik
Michał_Wójcik Member Posts: 13 ✭
edited September 2020 in Community Support
I'm using webhooks to check if a model has changed and then create a translation of the model each time it changes. I registered a webhook with 2 events: "onshape.model.lifecycle.changed" and "onshape.model.translation.complete". I get a notification on change, but when I create a translation, I never get the "complete" notification. When I check the translation by its ID manually, it's done and I can download it. I also tried registering a seperate webhook for translations, with the same document, workspace and element IDs, it still won't work. What should I do to get a notification? Or is it just broken and should be removed from documentation?

Answers

  • alan_baljeu
    alan_baljeu Member, User Group Leader Posts: 111 ✭✭
    I'm new to webhooks in onshape.  Where did you see these documented?  
    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

  • Michał_Wójcik
    Michał_Wójcik Member Posts: 13 ✭
    Right here.
  • Ethan_K
    Ethan_K Member, Onshape Employees Posts: 57 image
    @Michał_Wójcik
    You should be getting a notification upon completion - I think your understanding is correct. Can you include the exact request body you sent upon registering for the webhook?
  • Michał_Wójcik
    Michał_Wójcik Member Posts: 13 ✭
    edited October 2020
    {
      "events": ["onshape.model.lifecycle.changed","onshape.model.translation.complete"],
      "filter": "{$DocumentId} = '52c526d69a766eb4364973d3' && {$WorkspaceId} = '38cbdf8c8ebe22f18f17fc6a' && {$ElementId} = 'a3237df3ce503e27df514451'",
      "options": { "collapsibleEvents": "true" },
      "url": <my publicly visible dev server domain name>,
      "documentId": "52c526d69a766eb4364973d3"
    }

     Again, it works fine for the "onshape.model.lifecycle.changed" event.
  • grzegorz_kiernozek
    grzegorz_kiernozek Member Posts: 1 ✭
    @Ethan_K we will be gratefull for any help we can get with this,
    We do not have any info on model translation completion for now
  • mbattistello
    mbattistello Member, Developers Posts: 52 EDU
    Ive used this in the past and it worked as expected. I did have some general issues with webhooks and I believe it tied to how you need to handle multiple responses on them. Are you checking each of the responses or maybe just the first or last one in a series?

    Its been a while since Ive looked at the code I had so I dont remember the specifics. Let me try to find it and see if had commented it around some of the issues I saw in it. 


  • Michał_Wójcik
    Michał_Wójcik Member Posts: 13 ✭
    If every webhook notfication is its own request to my API, then I'm checking all of them. I log every request and I never got the translation.complete one.
  • Michał_Wójcik
    Michał_Wójcik Member Posts: 13 ✭
    Bump
  • mbattistello
    mbattistello Member, Developers Posts: 52 EDU
    Did you put a ticket in with API support? Ive used them in the past and they are very helpful. Just email your issue to api-support@onshape.com and it will create a ticket and they will work with you on it. 
  • Michał_Wójcik
    Michał_Wójcik Member Posts: 13 ✭
    Thanks for the info, I'll contact them