Forum Discussion

atatps_250754's avatar
atatps_250754
Icon for Altocumulus rankAltocumulus
Mar 05, 2018
Solved

Syntax Error when deploying iApp template using iControl ReST API

I have an iApp template that works great through TMSH but due to need for automation, I must to be able to deploy it via ReST. **Command:** curl -sku admin:admin -X POST -H "Content-type: applica...
  • atatps_250754's avatar
    Mar 08, 2018

    After much experimentation, I got it working. For anyone else who may find this useful:

     

    This is the original TMSH method of creating an iApp template:

     

    create test_template {
    actions replace-all-with {
    definition {
    html-help {
    
    }
    implementation {
    tmsh::create {
    ltm node 10.111.222.102
    address 10.111.222.102
    }
    tmsh::create {
    ltm node 10.111.222.103
    address 10.111.222.103
    }
    
    tmsh::create {
    ltm pool iApp-Automation-Test-ebiz-http
    members replace-all-with {
    10.111.222.102:80 {
    address 10.111.222.102
    }
    10.111.222.103:80 {
    address 10.111.222.103
    }
    }
    monitor http 
    }
    
    }
    macro {
    }
    presentation {
     insert apl script
    }
    }
    }
    description none
    requires-bigip-version-max none
    requires-bigip-version-min none
    requires-modules none
    }

    To convert the TMSH template code to ReST client (ARC or POSTMAN) syntax, you must replace all the line breaks with \n. In our case it would look like this:

     

    Method: POST
    URL: https://ltmip/mgmt/tm/sys/application/template/
    Body: {"name":"test_template","actions":[{"name":"definition","htmlHelp":"","implementation":"tmsh::create { \n ltm node 10.111.222.102 \n address 10.111.222.102 \n } \n tmsh::create { \n ltm node 10.111.222.103 \n address 10.111.222.103 \n } \n  \n tmsh::create { \n ltm pool iApp-Automation-Test-ebiz-http \n members replace-all-with { \n 10.111.222.102:80 { \n address 10.111.222.102 \n } \n 10.111.222.103:80 { \n address 10.111.222.103 \n } \n } \n monitor http  \n }","macro":"","roleAcl":["admin","manager","resource-admin"],"presentation":""}],"totalSigningStatus":"not-all-signed","requiresBigipVersionMax":"","ignoreVerification":"false","requiresModules":[""],"requiresBigipVersionMin":"11.0.0"}

    To convert to CURL, the additional step of escaping all the quotation marks must be taken:

     

    curl -sku admin:admin -X POST -H "Content-type: application/json" -d "{\"name\":\"test_template\",\"actions\":[{\"name\":\"definition\",\"htmlHelp\":\"\",\"implementation\":\"tmsh::create { \n ltm node 10.111.222.102 \n address 10.111.222.102 \n } \n tmsh::create { \n ltm node 10.111.222.103 \n address 10.111.222.103 \n } \n  \n tmsh::create { \n ltm pool iApp-Automation-Test-ebiz-http \n members replace-all-with { \n 10.111.222.102:80 { \n address 10.111.222.102 \n } \n 10.111.222.103:80 { \n address 10.111.222.103 \n } \n } \n monitor http  \n }\",\"macro\":\"\",\"roleAcl\":[\"admin\",\"manager\",\"resource-admin\"],\"presentation\":\"\"}],\"totalSigningStatus\":\"not-all-signed\",\"requiresBigipVersionMax\":\"\",\"ignoreVerification\":\"false\",\"requiresModules\":[\"\"],\"requiresBigipVersionMin\":\"11.0.0\"}" https://ltmip/mgmt/tm/sys/application/template

    Hope somebody finds this useful.