|
| 1 | +# Postman Integration |
| 2 | + |
| 3 | +The API Commandline Tool (ACT) exports all its commands into [postman-collection.json](postman-collection.json), which is consumable by [postman](https://www.getpostman.com/). Additionally, your environments can be exported into a format consumable by postman with `act.sh environment export <name>`. The following guide summaries the steps you need to take to get the API calls accessible within postman. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +Before you can get started, you need to install postman. You will find the right version for your operation system at [https://www.getpostman.com/downloads/](https://www.getpostman.com/downloads/). |
| 8 | + |
| 9 | +## Import Requests Collection |
| 10 | + |
| 11 | +On the main screen of postman you will find an **Import** button on the top left corner. Click on it and navigate to **Import from Link** and insert the following URL into the text box: |
| 12 | + |
| 13 | +``` |
| 14 | +https://raw.githubusercontent.com/Appdynamics/api-commandline-tool/master/postman-collection.json |
| 15 | +``` |
| 16 | + |
| 17 | +You will immediately see a new folder on the left called "AppDynamics API" with 60+ requests. If you open up that folder, you will see that the categories used by ACT are the names of the subfolders (e.g. application, dbmon, ...). If you open one of the commands you will see that the URL holds a variable called `{{controller_host}}` and that authorisation requires a `{{controller_user}}`, a `{{controller_account}}` and a `{{controller_password}}`. You can set those properties manually or you just can import one of your environments. |
| 18 | + |
| 19 | +## Import an environment |
| 20 | + |
| 21 | +To use ACT, you need to run `act config` or `act environment add` to configure a controller host and credentials. Those details are stored by act and you can export them into a format consumable by postman using `act.sh environment export <name>`: |
| 22 | + |
| 23 | +```json |
| 24 | +{ |
| 25 | + "name": "<name>", |
| 26 | + "values": [ |
| 27 | + { |
| 28 | + "key": "controller_host", |
| 29 | + "value": "http://<controllerurl>", |
| 30 | + "description": "", |
| 31 | + "enabled": true |
| 32 | + }, |
| 33 | + { |
| 34 | + "key": "controller_user", |
| 35 | + "value": "<user>", |
| 36 | + "description": "", |
| 37 | + "enabled": true |
| 38 | + }, |
| 39 | + { |
| 40 | + "key": "controller_account", |
| 41 | + "value": "<account>", |
| 42 | + "description": "", |
| 43 | + "enabled": true |
| 44 | + }, |
| 45 | + { |
| 46 | + "key": "controller_password", |
| 47 | + "value": "<password>", |
| 48 | + "description": "", |
| 49 | + "enabled": true |
| 50 | + } |
| 51 | + ], |
| 52 | + "_postman_variable_scope": "environment" |
| 53 | + } |
| 54 | +``` |
| 55 | + |
| 56 | +Copy the output of this command to your clipboard (on a mac you can run `./act.sh environment export demo2`) and go back to postman. Once again, click on **Import** and there open **Paste Raw Text**. Paste the content of your clipboard into the text area and click on **Import**. Immediately, you will see the name of your environment in the top right corner, where postman manages environments. Choose your imported environment before you run any commands. |
| 57 | + |
| 58 | +## Login & Send requests |
| 59 | + |
| 60 | +Some of the requests can be executed using Basic HTTP Authentication, so you can just open them up and click on **Send**. But many of the available commands are protected with a CSRF token. To obtain, this token run the command *AppDynamics API > controller > Authenticate.* The token will be stored as a variable automatically and from now on you are able to run any of the other commands. |
| 61 | + |
| 62 | +## Commands with parameters |
| 63 | + |
| 64 | +Many requests require you to provide a parameter like an application id or a json payload. Those parameters are exported as variables (e.g. `{{application}}` or `{{dashboard_id}}`), so you can configure them as environment variables or global variables to have them reusable. Otherwise, you can replace the variables with the required value. |
0 commit comments