Forum Discussion

martijnbrands_3's avatar
martijnbrands_3
Icon for Nimbostratus rankNimbostratus
Oct 15, 2018

PATCH IRule REST API in transaction not executed

Hello,

When I do a PATCH request to edit an IRule in an Transaction then the change is not executed. When I do a PATCH request without a transaction the change is executed. I do the change together with an Persistence change. Both changes are in the same transaction, the persistence change is executed the IRule is unchanged.The Transaction validate and transaction commit gives both a HTTP 200 result.

Do I miss something or is this a bug in the BIG IP REST API interface in cobination with F5 Transactions?

URL: mgmt/tm/ltm/rule/~Common~irule_persist_universal_example.test.nl-any-443

JSON payload:

{\"apiAnonymous\":\"when HTTP_REQUEST {\\n    
   if { [HTTP::cookie exists \\\"JSESSIONID\\\"] } {\\n
          persist uie [HTTP::cookie \\\"JSESSIONID\\\"] 9292\\n
   }\\n 
}\"}

2 Replies

  • Try this:

    !/bin/bash
    
    USERPASS='admin:admin'
    
     create a transaction and return the transaction ID
    transid=`curl -sk -u $USERPASS -H 'Accept: application/json' -H 'Content-Type: application/json' https://localhost/mgmt/tm/transaction -d '{}' |awk -F"," '{ print $1 }' |awk -F":" '{ print $2 }'`
    
     modify the iRule
    curl -sk -u $USERPASS -H "X-F5-REST-Coordination-Id: $transid" -H "Accept: application/json" -H "Content-Type: application/json" -X PATCH https://localhost/mgmt/tm/ltm/rule/~Common~test1-rule -d@irule.txt
    
     modify persistence
    curl -sk -u $USERPASS -H "X-F5-REST-Coordination-Id: $transid" -H "Accept: application/json" -H 'Content-Type: application/json' -X PATCH -d '{"persist":[{"name":"cookie"}]}' https://localhost/mgmt/tm/ltm/virtual/webserver-vip
    
     commit the transaction
    curl -sk -u $USERPASS -H "Accept: application/json" -H "Content-Type: application/json" -X PUT https://localhost/mgmt/tm/transaction/$transid -d '{ "state":"VALIDATING" }'
    

    where irule.txt is your iRule payload.

    {
    "apiAnonymous":" this is a test\n
    when HTTP_REQUEST {\n
      log local0. \"Hello World\"\n
    }"
    }