Share

Activity 2: Create the hook

For this activity, you will set up a webhook so that every time an item is updated, a callback is issued to Zapier, which will then perform the action you set up in activity 1.

Prerequisites

  • Ensure you have successfully completed activity 1.

Steps

  1. Generate a valid 3-Legged OAuth2 token using Postman.

  2. Use Postman to perform a call against the list of hooks created by your user to test your newly-generated OAuth2 token:

    1. Create a new call, change the verb to GET.

    2. Add the following URL:

      https://developer.api.autodesk.com/webhooks/v1/systems/adsk.flc.production/hooks.
    3. Click the Headers tab, and type a new parameter in the header: Content-Type: application/json.

  3. Click Send. If this is the first time you’re creating a hook, you should get a 200 OK code.

    Check for 200 OK code

    Tip:

    Refer to the Autodesk Platform Services Webhooks documentation for a list of all supported calls to manage hooks.

  4. Create the hook in APS Webhooks:

    1. Create a new call, change the verb to POST.

    2. Add the following URL:

      https://developer.api.autodesk.com/webhooks/v1/systems/adsk.flc.production/events/item.update/hooks
    3. Click the Headers tab, and type in two new parameters:

      Content-Type: application/json
      X-Tenant: TENANT 

      (TENANT should be typed in capital letters)

    4. Click the Body tab, paste the following payload as raw data:

      {
        "callbackUrl": "CALLBACK_URL_FROM_ZAPIER",
        "scope": {
        "workspace": "urn:adsk.plm:tenant.workspace:TENANT.WSID"
          }
      }
      Note:

      this is a simplified payload from the official documentation, and varies depending on which event is being triggered (specifically, the key inside the scope object).

      You need to customize the headers and payload with data specific to your site:

      • CALLBACK_URL_FROM_ZAPIER, This is the same URL you tested in step 7 of Part 2, generated by Zapier. You can always edit your Zap and get it again.
      • TENANT, Your site's name. Make sure the characters are all capitalized. Don’t forget that it should match the X-Tenant key in the Headers.
      • WSID, Workspace id where items are going to be updated and events triggered. Access to the workspace is required to create hooks for it. If access is lost, the webhook will fail and delivery follows back to the APS Webhooks Event Delivery guidelines
    5. Your request should look like the screenshots below. Press Send.

      Click send button

      Click the send button

    6. Your request should be completed successfully, and you should get a 201 Created response.

    7. If your Zap is created, you should now get an e-mail when items are updated in the workspace you identified when creating the hook. If your Zap is not finished, resume configuration from step 9 in Activity 1.

Tips and tricks

  • If you have a preview site, you can create hooks as well. Replace all occurrences of adsk.flc.production by adsk.flc.preview

  • By default, the payload sent to the callback URL contains just the item descriptor, and URN of the item (depending on the event, it contains a bit more info). If you need to fetch more data, you can retrieve it by performing a GET against

    https://your_site.autodeskplm360.net/api/v3/URN_OF_RESOURCE

    Example: To fetch item details data for the item.update event, perform a call against:

    https://TENANT.autodeskplm360.net/api/v3/urn:adsk.plm:tenant.workspace.item:TENANT.721.109597
  • You can also create hooks using curl:

    curl -X 'POST'
     -v 'https://developer.api.autodesk.com/webhooks-dev/v1/systems/adsk.flc.production/events/item.update/hooks'
     -H 'Content-Type: application/json'
     -H 'authorization: Bearer YOUR_BEARER_TOKEN'
     -d '{
          "callbackUrl": "CALLBACK_URL_FROM_ZAPIER",
          "scope": {
            "workspace": "urn:adsk.plm:tenant.workspace:TENANT.WSID"
            }
         }'

Activity 2 summary

In this activity, you set up a webhook so that every time an item is updated, a callback is issued to Zapier.

Was this information helpful?