This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UCMDB REST API for Policy Calculation

Hello Experts, I'm testing UCMDB REST APIs for Policy. I tried the below POST, which gives me a viewResultId in return. I understand this goes into the /policy/chunkForPath, but I'm not able to figure out how the body json for this API would look like. I tried in Swagger, but it throws error saying 'something went wrong'. I'm using a saas insatance.

Any examples, with screenshot would help. Thank you!

Tags:

  • Suggested Answer

    0  

    The steps are these:

    1) Get the specific compliance view which gives you a result containing the name, baseViewName and policyQueries using the endpoint: <UCMDB_Server>/rest-api/policy/complianceView/ViewName
    2) Next run the compliance view and get a result back using the endpoint: <UCMDB_Server>/rest-api//policy/calculate?chunckSize=300
    This will give a result like this:
    {
     "viewResultId" : eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1bmlxdWVfc2FsdCI6ImE4ZGZiNjAyLTRjNmItNDJhOC04YzdiLTdlMzBhNmRjNDM1MSIsInRpbWVzdGFtcF9zYWx0IjoxNjU1NDA4MTU5NTUxLCJ1c2VybmFtZSI6ImFkbWluOjE6VUNNREIifQ.Js7iFbI-pD84zq5VejzxnP28I6jSXlHWVKJemXpZS2M"
    }

    3) Next, calculate what is in the view execution passing a body for compliant like this:
    {
    'path':
    [
    {
    'pathElementId': 'COMPLIANT',
    'pathElementType': 'COMPLIANT'
    }
    ],
    'viewExecutionId': '<ID>'
    }

    using the method: <UCMDB_Server>/rest-api/uiserver/modeling/views/result/numberOfElementsForPath

    FYI, if you ever want to make sure you understand the calls and the payload, use the developer tools in chrome (or IE/Firefox)... to see the calls as you calculate this in the CMS UI.

    Not all REST API calls are exposed in SaaS, which may further compound the issue.  I can send you my rest.py example script which contains all the code to run a compliance view if you like, but it is too large to post here.

    Keith

    -- Hope this helps!

    Keith Paschal

    UCMDB Worldwide Support Lead