Share

Activity: Using impersonation and Zapier

In this activity, you use impersonation and Zapier to fetch data using the v3 API.

Steps

  1. Create an action in Zapier to process the URN of the item that was just updated, and split it up to have the workspace id and item id of the item for which the event was triggered.

    1. Add a new action after catching the hook, set it to Code.

    2. Select Run Javascript.

    3. Edit the template by picking the Payload Item Urn, returned by Fusion Manage via the hook.

      Edit the template

    4. Using Javascript coding – split the URN into an array, to get the site name, workspace id, and item id. You can use a simple script, such as:

      var splitUrn = inputData.urn.substring(inputData.urn.lastIndexOf(":") + 1);
      var splitUrnArray = splitUrn.split(".");
      var tenantName = splitUrnArray[0];
      var wsId = splitUrnArray[1];
      var itemId = splitUrnArray[2];
      var output = {tenantName: tenantName, wsId: wsId, itemId: itemId};

      Edit the template

    5. Run the script. You should see the following:

      Run a script

      These values are going to be available for this Zap, and with this, you can leverage pretty much any v3 API resource and fetch data.

      Now it’s time to fetch the owners of the items. However, for this, you’ll need a valid token to authenticate with Fusion Manage. For this example, we want this fetching to be done as another user in the system, which may (or may not) have access to the owners section of the item for which the event was triggered. In this case, we are going to impersonate that other user. The first step is to retrieve a 2-legged Oauth token – documented in the Autodesk Platform Services (APS) help.

  2. Fetch the owners of the items

    1. Add a new action after the Javascript code, select Webhooks by Zapier.

    2. Select Custom Request.

    3. Fill in the form:

      • Method: POST
      • URL:
      https://developer.api.autodesk.com/authentication/v1/authenticate.
      • Data: client_id=YOUR_FORGE_APP_CLIENT_ID&client_secret=YOUR_FORGE_APP_CLIENT_SECRET&grant_type=client_credentials&scope=data:read.
      • Headers: Content-Type: application/x-www-form-urlencoded.

      Fill in a form

    4. If everything went well, this will give you back an access_token

      Access token

  3. Now that you have an access token, it’s time to impersonate another user when calling Fusion Manage. Some important points to consider:

    1. Your APS app must be whitelisted in Fusion Manage, so that the system can let calls coming from that app into the site. If you have not done so, file a Support case to whitelist your APS app in Fusion Manage. You need to supply your client id. Do not share you client secret under any circumstance.
    2. You need the e-mail address of the user you want to impersonate.
  4. Time to get the owners of the item.

    1. Add a new action, select Webhooks by Zapier.

    2. Select GET.

    3. Fill in the URL:

      https://TENANT.autodeskplm360.net/api/v3/workspaces/WSID/items/ITEMID/owners.
    4. Fill in the headers:

    • X-user-id: The e-mail of the user you’re going to impersonate.

    • X-Tenant: TENANT.

    • Authorization: Bearer ACCESS_TOKEN IMPORTANT: Note the blank space between “Bearer” and the access token.

      Tip:

      Leverage Zapier’s inline editor to build this URL.

      Built url

    1. If everything goes well, you’ll get a success message, and the information about the owner of the item that was just updated will now be available to you:

      Owner output

    2. Success! Now you can notify the user, by using the longDesc field, which displays the e-mail address, to send him or her a notification. You can edit your existing action for that.

      alt

      alt

Was this information helpful?