This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Set hostname using REST API

Hi,

I really need to set the hostname parameter on an ip record in the IPAM database.

I am using the set node ip status in the orchestrator plugin to set a IP address as being used, but I really ned to add the hostname of the VM I am deploying on the ip node record.

How can this be done using REST?

This is the code being used for setting the status:

requestURL = "/Solarwinds/InformationService/v3/json/Invoke/IPAM.SubnetManagement/ChangeIpStatus";

payload = "[\"" + IP + "\",\"" + Status + "\"]";

Best Regards

Brian

  • Hi Brian,

    you could use CRUD Operations to update the hostname.

    And example would look like:

    Alias:

    Set-SwisObject $swis -Uri 'swis://localhost/Orion/IPAM.IPNode/IPAddress=1.1.1.1' -Properties @{ Alias = 'test1' }

    DNS Name:

    Set-SwisObject $swis -Uri 'swis://localhost/Orion/IPAM.IPNode/IPAddress=1.1.1.1' -Properties @{ DNSBackward = 'test1' }

    IPAM 4.7 API · solarwinds/OrionSDK Wiki · GitHub

    Kind Regards

    Rene

  • Sorry, i just realized you are working with rest api.

    Then it will look like:

    POST https://localhost:17778/SolarWinds/InformationService/v3/Json/swis://localhost/Orion/IPAM.IPNode/IPAddress=1.1.1.1

    Authorization: Basic YWRtaW46

    User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3

    Host: localhost:17778

    Accept: */*

    Content-Type: application/json

    Content-Length: 29

    {"Alias":"test1"}

  • Hi,

    Thank you for your reply.

    Unfortunately I cannot make it work.

    This is my test command:

    curl -k -v -u '<Service Account USERNAME>':'<Service Account PASSWORD>' 'https://<FQDN of server>:17778/SolarWinds/InformationService/v3/Json/swis://<FQDN of server>/Orion/IPAM.IPNode/IPAddress=<IP ADDRESS>' --request POST -H "Content-Type: application/json" -H "Content-Length: 22" -H "Accept: */*" -H "Host: <FQDN of server>:17778"  --data '{"Hostname":"Test123"}'

    This is the response from the server:

    {"Message":"Invalid key properties specified for entity IPAM.IPNode.\u000d\u000aParameter name: filter","ExceptionType":"System.ArgumentException","FullException":"System.ArgumentException: Invalid key properties specified for entity IPAM.IPNode.\u000d\u000aParameter name: filter\u000d\u000a   at SolarWinds.InformationService.Core.SwisUriResolver.ValidateAndResolveFilter(IEntityType entity, SwisUriFilter filter, Boolean isHosted)\u000d\u000a   at SolarWinds.InformationService.Core.SwisUriResolver.ValidateAndResolveUri(SwisUri uri, IQueryExecutionContext context)\u000d\u000a   at SolarWinds.InformationService.Core.SwisUriResolver.GetResolver(SwisUri uri, Boolean queryKeysOnly, IQueryProcessor queryProcessor, IQueryPlanCache queryPlanCache, IQueryExecutionContext context, ISiteEntityLookup siteEntityLookup)\u000d\u000a   at SolarWinds.InformationService.Core.CrudProcessor.Update(SwisUri uri, IDictionary`2 propertiesToUpdate, IQueryExecutionContext context)\u000d\u000a   at SolarWinds.InformationService.Core.Inf* Connection #0 to host <FQDN of server> left intact

    ormationService.Update(String uri, IDictionary`2 propertiesToUpdate)"}

    Any help will be greatly appreciated

    Best Regards

    Brian

  • Hi Brian,

    i think the problem are the properties. You are trying to access a field which does not exist.

    Try the same call with --data '{"DNSBackward":"Test123"}' or --data '{"SysName":"Test123"}' instead of --data '{"Hostname":"Test123"}'

    Edit: The field you are looking for should either be "DNSBackward" or "SysName".

    Kind Regards

    Rene

  • I did that already. Same error.

  • Could you try using the Ipnodeid of your testnode to update the hostname?

    it should look like:


    curl -k -v -u '<Service Account USERNAME>':'<Service Account PASSWORD>' '
    https://<FQDN of server>:17778/SolarWinds/InformationService/v3/Json/swis://<FQDN of server>/Orion/IPAM.IPNode/IpNodeId=12345' --request POST -H "Content-Type: application/json" -H "Content-Length: 22" -H "Accept: */*" -H "Host: <FQDN of server>:17778"  --data '{"Hostname":"Test123"}'

  • YEEES! That worked. Now how do I get the IpNodeId from an IP adress using rest?

  • Cool, i do not think we need the IpNodeid, i just wanted to make sure the call in general works.

    In the database the ipnodeid is an integer and for integer we do not the quotes. But the IP Address is a string, so we need to use quotes.

    Could you try the same call like:

    curl -k -v -u '<Service Account USERNAME>':'<Service Account PASSWORD>' 'https://<FQDN of server>:17778/SolarWinds/InformationService/v3/Json/swis://<FQDN of server>/Orion/IPAM.IPNode/IPAddress="1.1.1.1"' --request POST -H "Content-Type: application/json" -H "Content-Length: 22" -H "Accept: */*" -H "Host: <FQDN of server>:17778"  --data '{"Hostname":"Test123"}'

    (set the IP-address in double quotes)

  • That produces the error:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">

    <HTML><HEAD><TITLE>Bad Request</TITLE>

    <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>

    <BODY><h2>Bad Request - Invalid URL</h2>

    <hr><p>HTTP Error 400. The request URL is invalid.</p>

    </BODY></HTML>

    * Closing connection 0

    * TLSv1.2 (OUT), TLS alert, Client hello (1):

  • Ok, i did not expect that.

    But a get request to get the ipnodeid should not be a problem.

    Try this:

    GET https://localhost:17778/SolarWinds/InformationService/v3/Json/Query?query=SELECT+IpNodeID+FROM+IPAM_NODES+WHERE+IPAddress+LIKE+'1.1.1.1' HTTP/1.1
    Authorization: Basic YWRtaW46
    User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
    Host: localhost:17778
    Accept: */*