cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Not a customer? Start a free trial

Click the Start a free trial link to start a 15-day SaaS trial of our product and join our community as a trial user. If you are an existing customer do not start a free trial.

AppDynamics customers and established members should click the sign in button to authenticate.

Java (Java Agent, Installation, JVM, and Controller Installation)

Is there Rest APIs to create the HTTP request template and Actions/Policies?

Is there Rest APIs to create the HTTP request template and Actions/Policies?

Is there Rest APIs to create the HTTP request template & Actions/Policies?

 

I would like to automate the procedures for creating the HTTP request templates, Actions and policy.

By replying you agree to the Terms and Conditions of the AppDynamics Community.
Is there Rest APIs to create the HTTP request template and Actions/Policies?
6 REPLIES 6
Hiroki.Ito
AppDynamics Team


Thank you for posting to the community.

[HTTP request template]
There are "Export HTTP Request Action Templates from an Account" and "Import HTTP Action Templates into an Account" APIs.
First, you need to create a http action template from the controller UI, but you can export that template, modify the exported JSON, and import the modified JSON again with the new name to create http action templates by API.(You can't update/delete existing ones)
Please see the documents below for the APIs.
Export HTTP Request Action Templates from an Account
Import HTTP Action Templates into an Account

[Actions]
Please see the document below for "Create a New Action" API.

[Policies]
Please see the document below for "Create a Policy" API.

Best Regards,
Hiroki

Found something helpful? Click the Accept as Solution button to help others find answers faster.
Liked something? Click the Thumbs Up button.

Hi @Hiroki.Ito 

 

I had tried to import the API using the below payload, but it gives me an error:

error : 
Could not import Action Templates: the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is application/json;charset=UTF-8

--------------------------------

Payload :

[
    {
        "actionPlanType""httprequest",
        "name""Jitendra-http-request-test",
        "oneRequestPerEvent"false,
        "eventClampLimit"-1,
        "defaultCustomProperties": [],
        "method""POST",
        "scheme""HTTPS",
        "host""webexapis.com",
        "port"0,
        "path""/v1/messages",
        "query""",
        "urlCharset""UTF_8",
        "authType""NONE",
        "authUsername"null,
        "authPassword""",
        "headers": [
            {
                "id"0,
                "version"0,
                "name""Authorization",
                "value""Bearer OWIyNTUwMTAtOTNjZC00MjMzLWI4NzUtNWRlYTFlMGNhYjk3MmY4N2QwODUtN2Q4_PF84_1eb65fdf-9643-417f-9974-ad72cae0e10f"
            },
            {
                "id"0,
                "version"0,
                "name""content-type",
                "value""application/json"
            }
        ],
        "payloadTemplate": {
            "httpRequestActionMediaType""text/plain",
            "charset""UTF_8",
            "formDataPairs": [],
            "payload""{\n\"roomId\":\"Y2lzY29zcGFyazovL3VzL1JPT00vNDNlNGNiNjAtMDJjNi0xMWViLWE2YjctYjFiNWIyOTRmZWJh\",\n\"markdown\":\"# EUM Page Alert: \\n\\n Policy: ${policy.name} \\n\\n Event Type: ${latestEvent.eventType} \\n\\n Event: ${latestEvent.healthRule.name} \\n\\n ${latestEvent.eventMessage} \\n\\n For more details, please visit: ${latestEvent.deepLink}\"\n}"
        },
        "connectTimeoutInMillis"5000,
        "socketTimeoutInMillis"15000,
        "maxFollowRedirects"0,
        "responseMatchCriteriaAnyTemplate": [],
        "responseMatchCriteriaNoneTemplate": [],
        "testLogLevel""DEBUG",
        "testPropertiesPairs": [],
        "eventTypeCountPairs": []
    }]
----------------------------------------------------------------------------------
Hiroki.Ito
AppDynamics Team

Hi @Jitendra Singh.Jadav ,


Could you please share how you executed the API?

I tried in my local environment and following commands worked, so could you please try saving the payload as a file and then using a curl command?
 
  1. curl --user user1@customer1:your_password https://demo.appdynamics.com/controller/actiontemplate/httprequest > template.json
  2. edit template.json
  3. curl -X POST --user user1@customer1:your_password https://demo.appdynamics.com/controller/actiontemplate/httprequest -F file=@template.json

Best Regards,
Hiroki

Found something helpful? Click the Accept as Solution button to help others find answers faster.
Liked something? Click the Thumbs Up button.

Hi Hiroki,

 

I m able to do it with curl command but with POSTMAN its failing, not sure why.

 

POST  : https://cisco1nonprod.saas.appdynamics.com/controller/actiontemplate/httprequest

Auth : Basic Auth 

 

JitendraSinghJadav_0-1636471250872.pngJitendraSinghJadav_1-1636471306032.png

 

Also, 

I dont see the headers getting added after the template gets created.

I mentioned the  2 headers :
Authorization and Content-Type 

 

But both after the successful operation , I dont see it in the template.

JitendraSinghJadav_0-1636483476757.png

 

Hiroki.Ito
AppDynamics Team

 

Thank you for trying with curl.
When you use POSTMAN, could you please send a saved template file as body?
Please see attached screenshot for reference.
You can choose a file when you select form-data as body.
PostmanBody.png
For Custom Request Headers, I tried with the payload you attached in this post, and they were successfully registered.
CustomRequestHeaders.png
Could you please confirm if the template file contains headers and then try again?

 

Best Regards,
Hiroki
 

Found something helpful? Click the Accept as Solution button to help others find answers faster.
Liked something? Click the Thumbs Up button.