RestAPI from Netcool Impact RESTful API Data Source

Hello, I am trying to trigger a task in bigfix when receiving an alert in netcool impact. I setup the RESTful api data source in Netcool and I can connect fine to the bigfix server, does any one has examples of how to make the request from Inpact, looking for parameters etc.

Thanks.

Some additional information or context here may be useful, but to start the discussion, in order to execute a Task (action), the POST method against /api/actions can be used (https://developer.bigfix.com/rest-api/api/action.html). In this manner, you can either define a specific actionscript to be run, or you can reference an existing Fixlet or Task. The above link has example XMLs that can be POST’d for each approach.

Hello and thank you for the help, I have seen the page you talking about it and so far Insted of posting and action to bigfix I am trying to get some information back from it as a step into the solution by using

RESTfulAPIGET(“bigfix”,“api/help”, “relevance=(names of bes computers)”);

where RESTfulAPIGET is a function retrieves resources from a RESTful API. You can use the RESTfulAPIGET function to issue HTTP GET requests to RESTful APIs.

The log below shows that I can get to the Bigfix server, but the answer I was expecting is the list of computers, but instead I am getting the word “Context” back as per log below.

Thanks

!++++++++++( RESTfulAPIGET: Pre-Execution )+++++++++++
!RESTfulAPIGET-> Module: RESTfulAPIGET
!-----------
!RESTfulAPIGET-> Datasource: bigfix (String)
!RESTfulAPIGET-> Path: api/help (String)
!RESTfulAPIGET-> Config: relevance=(names of bes computers) (String)
!RESTfulAPIGET-> DataItem: null
!RESTfulAPIGET-> DataItems: null
!----------( RESTfulAPIGET: Pre-Execution )-----------
22 Dec 2017 11:59:08,953: [IPLtoXML_Test_Julio][pool-2-thread-3364]
!++++++++++( RESTfulAPIGET: Post-Execution )+++++++++++
!RESTfulAPIGET-> Module: RESTfulAPIGET
!-----------
!RESTfulAPIGET-> Datasource: bigfix (String)
!RESTfulAPIGET-> Path: api/help (String)
!RESTfulAPIGET-> Config: relevance=(names of bes computers) (String)
!RESTfulAPIGET-> DataItem: null
!RESTfulAPIGET-> DataItems: null
!----------( RESTfulAPIGET: Post-Execution )-----------
22 Dec 2017 11:59:08,953: [IPLtoXML_Test_Julio][pool-2-thread-3364]Parser log: Context

The REST API endpoint that is used to evaluate and return session relevance is /api/query (https://developer.bigfix.com/rest-api/api/query.html), whereas in the log snippet above, it appears you are attempting a GET request against /api/help.

Your GET request should look something like:

https://bigfix:52311/api/query?relevance=(names%20of%20bes%20computers)

1 Like

hell Aram and again thank you for your continuous help…
the RESTfulAPIGET function in netcool/impact RESTfulAPIGET(“datamodelname”, “path”, “config”)

Now I was trying to parse as above
RESTfulAPIGET(“bigfix”,“api/help”, “relevance=(names of bes computers)”);
which you rightful pointed out was wrong…however doing some more digging I found the following command works perfectly and I can log the correct answer from BigFix.
RESTfulAPIGET(“bigfix”,"/api/query?relevance=(names%20of%20bes%20computers)", “”:wink:
Noted Config part being Null

hurraaaaaaaaa!!!

what I need to figure next out is how to use the post command which reads:
RESTfulAPIPOST(“datamodelname”, “path”, “config”)
the question here is how to Add the xml string (which is the correct one (I tried to add here but the forum do not post the whole thing…

<?xml version="1.0" encoding="utf-8"?><BES SkipUI="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SingleAction>
        <Title>Test Action 10</Title>
        <Relevance>true</Relevance>
        <ActionScript>command that I want to run</ActionScript>
        <SuccessCriteria />
        <Settings />
        <SettingsLocks />
        <Target>
			<ComputerName>computername</ComputerName>
		</Target>
    </SingleAction>
</BES>

to the “path” part?

I tried:
path1="/api/actions"+xml;
(where xml is the whole xml string above)
result=RESTfulAPIPOST(“bigfix”, path1, Config);

But the log says that I can not connect with the bigfix server (knowing that the get command works perfectly, I can only assume that bigfix do not like the xml in the path???)

do you know when you have an xml and you want to create an action as describes in the documentation as below, where the actual xml should go?

POST/api/actionsCreates a new action.
Request: BES XML for the action.

For example:

<?xml version="1.0" encoding="utf-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SkipUI="true">
    <SingleAction>
        <Title>test action</Title>
        <Relevance>true</Relevance>
        <ActionScript>setting "test action"="{now as string}" on "{now}" for client</ActionScript>
        <SuccessCriteria />
        <Settings />
        <SettingsLocks />
        <Target>
            <AllComputers>true</AllComputers>
        </Target>
    </SingleAction>
</BES>

(I edited your post to put the XML inside the “Preformatted Text” tag so the XML is readable).
You can do this by highlight your text and selecting the “Preformatted Text” option:

1 Like

Your XML looks fine I think. You just put that XML in the post body. Depending on the tool your using, you do have to make sure your posting with the header Content-Type text/html; charset=UTF-8

That one threw me for a loop before I figured that one out.

Hope that’s helpful.

1 Like

You cannot POST data as path (query) parameter as far as I know. It should be part of your Config object.

I’m not able to test it, but I think you should prepare variables for your call like this:

var data = '<?xml version="1.0" encoding="utf-8"?>\
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SkipUI="true">\
    <SingleAction>\
        <Title>test action</Title>\
        <Relevance>true</Relevance>\
        <ActionScript>setting "test action"="{now as string}" on "{now}" for client</ActionScript>\
        <SuccessCriteria />\
        <Settings />\
        <SettingsLocks />\
        <Target>\
            <AllComputers>true</AllComputers>\
        </Target>\
    </SingleAction>\
</BES>';
var headers = { "Content-Type": "application/xml" };
var Config = { "Data": data, "Headers": headers };
var path1="/api/actions";

And then make your call
var result=RESTfulAPIPOST("bigfix", path1, Config);

1 Like

Hello Jason, thank you very much, I did not know about that function, many thanks

hello you are correct, I had that in place. thanks

Hello Roman, looking at your code made me realize that I was being crazy as I was trying to use the native language for Netcool/Impact which is IPL when in fact I could be using java as it is accepted by the tool also.
Creating the whole solution in java and following your example, I was able to create the action in bigfix and get it to execute.

Fantastic help, thank you very much!!!

1 Like

I know this is an old thread, but it is exactly what I am looking for :slight_smile:

I was starting to look at this also. Would you be able to share the java code that you used?

Thanks