Goal
Troubleshoot errors from the Acquia DAM API.
Overview
Learning something new can be challenging, and working with a new API is no exception. It can often be daunting to read through the documentation with no guidance, so we’ve put together this guide to help get you started. We will focus on two Acquia DAM (Widen) API endpoints, and cover some basic response codes and errors you might encounter.
First, we will go over how to request a list of upload profiles available to the API user through the List All Upload Profiles endpoint. Afterwards we will describe how to use an upload profile’s UUID from the response with the Upload A File endpoint to create a new asset. If you’re not familiar with Upload Profiles, we recommend this article to get started.
Along the way we’ll provide general tips, code snippets and common errors. Lastly, we’ll provide the full code example for you to work with.
Our example is written in C# but the concepts can be applied to any language. If you’re just looking to test the behavior of the endpoints, without wanting to write any code, we recommend using Postman.
-
Getting Started
Before we can dive into the code you’re going to need a few DAM specific items to get started. You’ll need a valid API token with permission to View and Upload with at least one Upload Profile, and the ability to edit metadata for your chosen asset(s).
If you do not have this, you will need to work with your site’s administrator to generate a token with these permissions.
You’ll also need to ensure that your environment and IDE are correctly configured for C#.
-
Authorization
We will be using a Bearer token as our form of authentication, as required by our API. We are storing it as a global variable for access across our methods. While this isn’t generally the best practice, it is sufficient for our example.
To begin, create variables to hold the token and the base endpoint for the appropriate version of the API. We will be using the V2 API because it is our most current version and has the best performance.
Uri baseAddress = new Uri("https://api.widencollective.com/v2/");string token = "Bearer __API__TOKEN__HERE"; -
List All Upload Profiles Endpoint
Now that the authentication and base endpoint are set up, we can begin working with the API.
The first endpoint we’ll visit is the List All Upload Profiles endpoint. It’s a simple GET request that retrieves all available Upload Profiles. To see what data the endpoint needs we can check the Assets > Creating New Assets section of our documentation. Reviewing the documentation, we can see that for “List All Upload Profiles'', all we have to do is make sure our Bearer Token and URL are correct, and we should be good to go.