How To Access ArcGIS Monitor Data Through the API

851
6
01-19-2024 12:28 PM
GeoJosh
Esri Regular Contributor
5 6 851

Table of Contents

 

Introduction

ArcGIS Monitor 2023 collects and generates endless amounts of useful data. The software itself ships with a number of tools to help you make sense of all this data; Collections help you organize components into logical groupings and Analysis Views help you identify trends in the data. There may be times that you need to programmatically access the data so that you can extend ArcGIS Monitor in a custom way. To do so, you must first acquire an authentication token.

In this article, I will demonstrate how to acquire an authentication token for ArcGIS Monitor using Postman. Postman is a tool that is popular in the web development world for testing and interacting with APIs. It allows you to define requests and organize them into collections. You can learn more about Postman here. After we have acquired an access token, I will demonstrate how to include the token in a request to ArcGIS Monitor to obtain data.

Please note: The ArcGIS Monitor API is currently a beta feature and is not supported by Esri Support. Please use caution and thoroughly test these workflows in non-production environments first.

 

Obtain an Access Token

1. In Postman, create a new Collection.

GeoJosh_0-1705596833359.png

 

2. Create a new POST request inside the new Collection

GeoJosh_3-1705597046875.pngGeoJosh_1-1705596895329.png

 

 

 

3. In the URL textbox, type in the URL to the token generation endpoint.

GeoJosh_0-1705611573660.png

 

4. Click Body, select raw, and choose JSON for content type.

GeoJosh_0-1705676421110.png

 

5. The request body object should have two keys: username and password. Define a new JSON object and add these keys with their respective values:

GeoJosh_1-1705676475598.png

 

6. Send the request! The response body will contain four keys but I only want to call out two of them right now:

  • access_token: The token that will be used to authenticate future requests.
  • expires_in: How long (in seconds) the token can be used before another needs to be generated.

GeoJosh_2-1705676519426.png

 

7. Copy the value of access_token and paste it in your favorite text editor.

 

Use the Access Token to Obtain Data

In this section, we will walk through how to use the access token generated above to query ArcGIS Monitor for metrics data.

 

1. Follow steps 2 through 4 above to create a new request. When defining the URL in step 3, use the URL to the metrics data query endpoint instead:

GeoJosh_7-1705673943722.png

 

2. Click Authorization and choose Bearer Token for type. For Token, paste the access token from step 7 above.

GeoJosh_8-1705674090943.png

 

4. Click Body, select raw, and choose JSON for content type.

GeoJosh_9-1705674785068.png

 

5. I am interested in the metrics data for a specific metric, so I will specify a where clause that targets a metric by it's ID:

GeoJosh_10-1705674990334.png

 

6. Send the request! The body will contain a key called features which is an array of metrics data for the metric I specified.

GeoJosh_11-1705675062775.png

 

What Next?

In this article, I demonstrate how to use a REST client (Postman) to get an access token for ArcGIS Monitor and how to use that token to obtain Monitor data. Manually obtaining this data via Postman might not be ideal, so please use these examples as guides that help you extend the ArcGIS Monitor application  through scripting and other applications.

 

Learn More

ArcGIS Monitor

ArcGIS Monitor Information Model

ArcGIS Monitor on Esri Community

Introduction to ArcGIS Monitor

6 Comments