Layer 7 API Management

Expand all | Collapse all

Restman update policy issue

Jump to Best Answer
  • 1.  Restman update policy issue

    Posted 12-14-2017 05:10 PM

    Hello,

     

    I have problem of updating CA API Gateway Policy

     

    "url": "https://<ip>:9443/restman/1.0/policies/24e6fd7c5b6fb3a96690246c8ac492ec",

    "method": "PUT",

    "body":

    <l7:Policy version="0" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
    <l7:PolicyDetail version="0">
    <l7:Name>#OTK OVP Configuration</l7:Name>
    <l7:PolicyType>Include</l7:PolicyType>
    <l7:Properties>
    <l7:Property key="revision">
    <l7:LongValue>1</l7:LongValue>
    </l7:Property>
    <l7:Property key="soap">
    <l7:BooleanValue>false</l7:BooleanValue>
    </l7:Property>
    </l7:Properties>
    </l7:PolicyDetail>
    <l7:Resources>
    <l7:ResourceSet tag="policy">
    <l7:Resource type="policy">
    <?xml version="1.0" encoding="UTF-8"?> <wsp:Policy xmlns:L7p="http://www.layer7tech.com/ws/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"> <wsp:All wsp:Usage="Required"> <L7p:CommentAssertion> <L7p:Comment stringValue="Target Configuration Policy: &quot;OTK OVP Configuration&quot;"/> </L7p:CommentAssertion> <L7p:CommentAssertion> <L7p:Comment stringValue="=== Set custom values for Context Variables below ==="/> </L7p:CommentAssertion> <L7p:CommentAssertion> <L7p:Comment stringValue="=== Add any new Context Variables or extensions below ==="/> </L7p:CommentAssertion> </wsp:All> </wsp:Policy>
    </l7:Resource>
    </l7:ResourceSet>
    </l7:Resources>
    </l7:Policy>

     

    The error message is

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <l7:Error xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
    <l7:Type>BadRequest</l7:Type>
    <l7:TimeStamp>2017-12-14T17:06:59.672-05:00</l7:TimeStamp>
    <l7:Link rel="self" uri="https://*********:9443/restman/1.0/policies/24e6fd7c5b6fb3a96690246c8ac492ec"/>
    <l7:Detail>HTTP 400 Bad Request. Caused by: The processing instruction target matching &quot;[xX][mM][lL]&quot; is not allowed.</l7:Detail>
    </l7:Error>

     

    Did I do anything wrong here?

     

    Regards,

    Naichun



  • 2.  Re: Restman update policy issue
    Best Answer

    Posted 12-19-2017 11:16 AM

    I think I figured it out, for updating a existing policy

    1) guid is required

    2) id is required

    3) version is required ( the value should be the latest version number, you can retrieve the version via API GET )

    4) <l7:Resource type="policy"> contains a one-line string which needs to be encoded from xml to ASCII

     

    Working example

    <l7:Policy guid="b8d40c59-c97f-455a-806a-**********" id="24e6fd7c5b6fb3**********" version="{{ tmpxmlhash.version.0 }}" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
    <l7:PolicyDetail folderId="bc9a31b7578652a08a514d7d4fef25f3" guid="b8d40c59-c97f-455a-806a-***********" id="24e6fd7c5b6fb3a9669024********" version="{{ tmpxmlhash.version.0 }}" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
    <l7:Name>#OTK id_token configuration</l7:Name>
    <l7:PolicyType>Include</l7:PolicyType>
    <l7:Properties>
    <l7:Property key="revision">
    <l7:LongValue>2</l7:LongValue>
    </l7:Property>
    <l7:Property key="soap">
    <l7:BooleanValue>false</l7:BooleanValue>
    </l7:Property>
    </l7:Properties>
    </l7:PolicyDetail>
    <l7:Resources>
    <l7:ResourceSet tag="policy">
    <l7:Resource type="policy">
    &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;wsp:Policy xmlns:L7p=&quot;http://www.layer7tech.com/ws/policy" xmlns:wsp=&quot;http://schemas.xmlsoap.org/ws/2002/12/policy"> &lt;wsp:All wsp:Usage=&quot;Required&quot;&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;Target Configuration Policy: &amp;quot;OTK id_token configuration&amp;quot;&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;=== Set custom values for Context Variables below ===&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;=== Add any new Context Variables or extensions below ===&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;L7p:SetVariable&gt; &lt;L7p:AssertionComment assertionComment=&quot;included&quot;&gt; &lt;L7p:Properties mapValue=&quot;included&quot;&gt; &lt;L7p:entry&gt; &lt;L7p:key stringValue=&quot;LEFT.COMMENT&quot;/&gt; &lt;L7p:value stringValue=&quot;==&quot;/&gt; &lt;/L7p:entry&gt; &lt;L7p:entry&gt; &lt;L7p:key stringValue=&quot;RIGHT.COMMENT&quot;/&gt; &lt;L7p:value stringValue=&quot;// Issuer Identifier (including protocol and port)&quot;/&gt; &lt;/L7p:entry&gt; &lt;/L7p:Properties&gt; &lt;/L7p:AssertionComment&gt; &lt;L7p:Base64Expression stringValue=&quot;{{ url_dmz_gateway }}&quot;/&gt; &lt;L7p:VariableToSet stringValue=&quot;iss&quot;/&gt; &lt;/L7p:SetVariable&gt; &lt;/wsp:All&gt; &lt;/wsp:Policy&gt;
    </l7:Resource>
    </l7:ResourceSet>
    </l7:Resources>
    </l7:Policy>

     

    About the LongValue, I am not sure why we need it, the value could be an integer and no need to be updated it , e.g. could always be set to 2.

     

    Regards,

    Naichun