Using REST API to retrieve computer by IP Address

I am trying to retrieve computers by a specific IP address, but it isn’t working.

I am using URL:

https://xxxx.xxx.xxx:52311/api/query?relevance=(id of it) of bes computers whose ( ip address of it as string contains "9.12.234.182" )

The Result is null with return code 200 and msg of OK. The IP Address is in an entry on the server.

What is wrong with query?

Can’t spot any errors with your Relevance Statement.
What do you get when you enter the statement into Web Report QNA?

https://WebReportsServer:52312/webreports?page=QNA

The relevance query usually needs to be in quotes with the inner quotes escaped. You may need to escape the spaces as well in some cases.

How are you making the REST call? cURL?

When I click on this link, I get server not found

You need to replace the link with that of your server.

1 Like

I am using curl. Here are the results.

curl -k -n "https://ROOT_SERVER_FQDN:52311/api/query?relevance=(id%20of%20it)%20of%20bes%20computers%20whose%20(%20ip%20address%20of%20it%20as%20string%20contains%20%229.12.248.58%22%20)"
<?xml version="1.0" encoding="UTF-8"?>
<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
    <Query Resource="(id of it) of bes computers whose ( ip address of it as string contains &quot;9.12.248.58&quot; )">
        <Result></Result>
        <Evaluation>
            <Time>16.953ms</Time>
            <Plurality>Plural</Plurality>
        </Evaluation>
    </Query>
</BESAPI>

Here are IP Address contents when isting by ID

            <Property Name="IP Address">10.112.80.58</Property>
            <Property Name="IP Address">9.12.248.58</Property>
            <Property Name="IPv6 Address">fe80:0:0:0:408:69ff:fec1:dba8</Property>

I am getting unable to connect. Sending note to owner of the server regarding port 52312

Here is curl data returned:

<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
    <Query Resource="(id of it) of bes computers whose ( ip address of it as string contains &quot;9.12.248.58&quot; )">
        <Result></Result>
        <Evaluation>
            <Time>16.953ms</Time>
            <Plurality>Plural</Plurality>
        </Evaluation>
    </Query>
</BESAPI>

Lets try again to post result from curl command:

Query Resource="(id of it) of bes computers whose ( ip address of it as string contains &quot;9.12.248.58&quot; )"

I think I found the problem. I went to the webreports?page=QNA

I entered this query:

Q: (id of it) of bes computers whose ( ip address of it as string contains "9.12.188.54" )
A: 10070881

This computer has only one IP Address property
Property Name=“IP Address”>9.12.188.54</Property

I then did:

Q: (id of it) of bes computers whose ( ip address of it as string contains "9.12.248.58" )
No answer was returned on evaluate.

I noticed that this computer has 2 IP Address property stanzas

Property Name="IP Address">10.112.80.58</Property

Property Name="IP Address">9.12.248.58</Property

I also tried using IP Address 10.112.80.58 with no answer returned.

I looks like if there is more than one IP Address property stanza the computer entry isn’t found.
I tried using property name ips9, but got error ips9 not valid.

Where do I go from here?

ids of bes computers whose ( exists ip address whose (it as string contains "9.12.248.58") of it )
1 Like

that worked, thank you.

1 Like

I fixed your posts above so the contents you pasted in show up properly.

You just need to highlight the code / XML / etc… and click the </> button in the toolbar.

Also, it just occurred to me that it is probably better to use IP Addresses in private IP space for working out examples like this. ( Like: 192.168.1.x )

You generally should redact any server domain names and public IP addresses from forum posts.

Can we get the list of all the computers by an array ip address ?