Accessing the Deskpro REST API

The Application Client provides an http client that your application can use to make requests to the Deskpro instance which is hosting the application.

The advantage of using the builtin client is that it saves you from worrying about the API authentication. The client will always use the credentials of the currently signed user.

How does it work?

You only need to obtain a reference to the Rest API Client from the Application Client. The following snippet will show you how to fetch the data for the signed in user

  // obtain a reference to the Custom Fields Client from the Application Context

  const { 
      /**
       * @see https://deskpro.github.io/apps-sdk-core/reference/DeskproAPIClient.html
       */
      restApi
  } = dpapp;

  restApi.get('me').then(response => console.log(response.body))

You don't need to specify the full URL of your resource, only the relative path. This client only supports the v2 API which you can inspect by going to the following url: http://{your-deskpro-instance}/api/v2/doc

Last updated