DX Unified Infrastructure Management

  • 1.  Using probe callbacks with RESTful webservice

    Posted Nov 04, 2015 02:04 PM

    I'm having a difficult time in properly formatting a POST request to target various probe callbacks when using the RESTful webservice.  The documentation has me a bit confused, so I'm hoping someone has gotten this to work and can explain it to me.

     

    From the documentation, the "Invoke Callback" and "Invoke Callback2" API calls are to be sent as a POST with an XML or JSON formatted request.  There is one example in the documentation for invoking the get_info callback on the controller probe.  Using the example, I'm able to properly trigger the callback and get information back.

     

    This is the example request that works for me:

    POST /rest/probe/chris-dev/primaryhub/nb-1538/controller/callback/get_info HTTP/1.1 Accept: application/xml Content-Type: application/xml  <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <callbackrequest>      <timeout>5000</timeout>      <parameters>           <name>detail</name>           <type>int</type>           <value>1</value>      </parameters> </callbackrequest>

     

    When looking at the callback in the Probe Utility, there are 2 parameters that can be sent (both are optional), but they do not align with anything in the example XML above.  The 2 possible parameters are "interfaces" and "robot".  This example works fine for any callback where I don't need to send an actual parameter, but for those that I do need/want to send a parameter, I can't work out what a proper request should look like.

     

    Based on the parameters available in the Probe Utility for the controller probe, I would expect the request to look like this (and would use a similar format for other probes), but this doesn't work, so I am obviously not understanding the <parameters> section of the XML.

    POST /rest/probe/chris-dev/primaryhub/nb-1538/controller/callback/get_info HTTP/1.1 Accept: application/xml Content-Type: application/xml  <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <callbackrequest>      <timeout>5000</timeout>      <parameters>           <name>interfaces</name>           <type>integer</type>           <value>1</value>      </parameters>      <parameters>           <name>robot</name>           <type>string</type>           <value>hostname</value>      </parameters> </callbackrequest>

     

    Anyone know how to actually send parameters to the probe callbacks using the RESTful webservice?



  • 2.  Re: Using probe callbacks with RESTful webservice

    Broadcom Employee
    Posted Jun 02, 2016 04:34 PM

    Accept: application/xml

    Content-Type: application/xml

     

    body

     

     

    <nimPds>

      <nimInt key="newInt">1</nimInt>

      <nimInt key="newInt2">2</nimInt>

      <nimInt key="newInt3">3</nimInt>

      <nimString key="newString1">This is a string value 1</nimString>

      <nimString key="newString2">This is a string value 2</nimString>

      <nimIntTable key="IntTable1">

      <int index="0">1</int>

      <int index="1">2</int>

      <int index="2">3</int>

      </nimIntTable>

      <nimIntTable key="IntTable12">

      <int index="0">1</int>

      <int index="1">2</int>

      <int index="2">3</int>

      </nimIntTable>

      <nimStringTable key="StringTable1">

      <string index="0">String in a table 11</string>

      <string index="0">String in a table 12</string>

      <string index="0">String in a table 13</string>

      </nimStringTable>

      <nimPds>

      <nimInt key="newInt">1</nimInt>

      <nimInt key="newInt2">2</nimInt>

      <nimInt key="newInt3">3</nimInt>

      <nimString key="newString1">This is a string value 1</nimString>

      <nimString key="newString2">This is a string value 2</nimString>

      <nimPds>

      <nimIntTable key="IntTable1">

      <int index="0">1</int>

      <int index="1">2</int>

      <int index="2">3</int>

      </nimIntTable>

      <nimStringTable key="StringTable2">

      <string index="0">String in a table 11</string>

      <string index="0">String in a table 12</string>

      <string index="0">String in a table 13</string>

      </nimStringTable>

      <nimPds>

      <nimIntTable key="IntTable1">

      <int index="0">1</int>

      <int index="1">2</int>

      <int index="2">3</int>

      </nimIntTable>

      </nimPds>

      </nimPds>

      </nimPds>

      <nimPds>

      <nimIntTable key="IntTable1">

      <int index="0">1</int>

      <int index="1">2</int>

      <int index="2">3</int>

      </nimIntTable>

      </nimPds>

      <nimPds>

      <nimStringTable key="StringTable0">

      <string index="0">String in a table 11</string>

      <string index="0">String in a table 12</string>

      <string index="0">String in a table 13</string>

      </nimStringTable>

      <nimStringTable key="StringTable1">

      <string index="0">String in a table 11</string>

      <string index="0">String in a table 12</string>

      <string index="0">String in a table 13</string>

      </nimStringTable>

      </nimPds>

    </nimPds>

     

    The details for this can be found below:

    https://docops.ca.com/ca-unified-infrastructure-management-probes/en/probe-development-tools/restful-web-services/call-reference/probe-calls#ProbeCalls-InvokeCallback2



  • 3.  Re: Using probe callbacks with RESTful webservice

    Broadcom Employee
    Posted Aug 04, 2016 01:12 PM

    Ryan - did Gene's response answer your question?



  • 4.  Re: Using probe callbacks with RESTful webservice
    Best Answer

    Posted Aug 04, 2016 01:46 PM

    Not really; I had read the documentation that he posted but was not understanding it.  Also, his answer was for callback2, I was trying to use callback.  I did eventually find that the problem was that I was defining an integer parameter as integer, when it should be int.

     

    This is what worked for me:

     

    POST /rest/probe/chris-dev/primaryhub/nb-1538/controller/callback/get_info HTTP/1.1  
    Accept: application/xml  
    Content-Type: application/xml  
      
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>  
    <callbackrequest>  
         <timeout>5000</timeout>  
         <parameters>  
              <name>interfaces</name>  
              <type>int</type>  
              <value>1</value>  
         </parameters>  
         <parameters>  
              <name>robot</name>  
              <type>string</type>  
              <value>hostname</value>  
         </parameters>  
    </callbackrequest>  
    


  • 5.  Re: Using probe callbacks with RESTful webservice

    Broadcom Employee
    Posted Aug 04, 2016 01:49 PM

    Hi Ryan - so it was a datatype definition issue then correct?



  • 6.  Re: Using probe callbacks with RESTful webservice

    Posted Aug 04, 2016 01:51 PM

    Correct.



  • 7.  Re: Using probe callbacks with RESTful webservice

    Posted Apr 05, 2018 08:00 AM

    Hi,

     

    When I send a POST request to callback, i'm getting  message as "This method is not available to account users." though i have Administrator privilege. Can someone help? how can i fix this? 

     

    Thanks 



  • 8.  RE: Using probe callbacks with RESTful webservice

    Posted Jul 03, 2019 05:18 PM
    I was reading this thread and had a similar issue.

    I am trying to get the response for callback "directory_list" on "logmon" probe.

    I tried the below payload by providing all the parameters(6) still seems the response is not correct, though I get a 200 OK response.

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

    <callbackrequest>

      <timeout>5000</timeout>

      <parameters>

        <name>directory</name>

        <type>string</type>

        <value>/path/to/log/file/</value>

      </parameters>

      <parameters>

        <name>pattern</name>

        <type>string</type>

        <value>sample.log</value>

      </parameters>

      <parameters>

        <name>user</name>

        <type>string</type>

        <value></value>

      </parameters>

      <parameters>

        <name>password</name>

        <type>string</type>

        <value></value>

      </parameters>

      <parameters>

        <name>type</name>

        <type>int</type>

        <value>0</value>

      </parameters>

      <parameters>

        <name>detail</name>

        <type>int</type>

        <value>0</value>

      </parameters>

    </callbackrequest>

    Request URL I am using: 

    https://host:port/rest/probe/{domain}/{hub}/{robot}/logmon/callback/directory_list

    Response from server:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <pds />

    The same parameters are working if I use the Infrastructure Manager Probe Utility, but not the rest API.

    Could someone have any idea what could be wrong in the request?

    Thanks for your help.