Splunk AppDynamics

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

Jitendra_Singh_
Explorer

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.

Labels (1)
0 Karma

Hiroki_Ito
Contributor

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

Jitendra_Singh_
Explorer

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": []
    }]
----------------------------------------------------------------------------------
0 Karma

Hiroki_Ito
Contributor

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
0 Karma

Jitendra_Singh_
Explorer

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 

image.pngimage.png

0 Karma

Jitendra_Singh_
Explorer

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.

image.png

0 Karma

Hiroki_Ito
Contributor
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.
image.png
For Custom Request Headers, I tried with the payload you attached in this post, and they were successfully registered.
image.png
Could you please confirm if the template file contains headers and then try again?
Best Regards,
Hiroki
 
0 Karma
Get Updates on the Splunk Community!

Get Schooled with Splunk Education: Explore Our Latest Courses

At Splunk Education, we’re dedicated to providing incredible learning experiences that cater to every skill ...

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL  The Splunk AI Assistant for SPL ...

Buttercup Games: Further Dashboarding Techniques (Part 5)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...