Reply

Trying to set a static IP

MRojas
Techie
Posts: 4
6912     0
I'm just starting to use the Infoblox WAPI. I'm trying to set it up so I can call the WAPI from my ASP.NET application to set a static IP given an IP and a MAC address. I tried to run the following two commands through the Chrome REST console, but both came back with "Error": "AdmConProtoError: Unknown object type" (Assume the infoblox server name is "infoblox") https://infoblox/wapi/v1.0/record:host -d '{"ipv4addrs":[{"configure_for_dhcp": false, "ipv4addr": "10.222.0.15"}], "configure_for_dns": false}' https://infoblox/wapi/v1.0/record: host_ipv4addr -d '{"ipv4addr":"10.222.0.15","configure_for_dhcp":false,"mac":"01:23:45:01:23:45"} What am I doing wrong? Which command should I be using?

Name required

BAndersen Employee
Employee
Posts: 15
6912     0

Reading the WAPI 1.2.1 Docs for NIOS 6.8.5 under Support-->Download it indicates that a "name" is required on create.  See page 415-416 for CURL examples (make sure the zone and network exists first):

curl -k3 -u admin:testpw -H "Content-Type: application/json" \

-X POST https://192.168.1.2/wapi/v1.2.1/record:host -d \

’{"ipv4addrs":[{"ipv4addr":"10.222.0.12"}],"name":"host.zone.com"}’

WAPI 1.2.1

BAndersen Employee
Employee
Posts: 15
6912     0

Ah,

  I also see that you are using WAPI 1.0.  There are lots of new features in 1.2.1 if you can get your NIOS up to 6.8.4.

Hope this helps,

Brad

No change

MRojas
Techie
Posts: 4
6912     0
I tried adding a name, and still got the error: "Error": "AdmConProtoError: Unknown object type (record:host {\"ipv4addrs\":[{\"ipv4addr\": \"10.222.0.15\"}], \"name\": \"Test\"})", "code": "Client.Ibap.Proto", "text": "Unknown object type (record:host {\"ipv4addrs\":[{\"ipv4addr\": \"10.222.0.15\"}], \"name\": \"Test\"})"

Content-type?

BAndersen Employee
Employee
Posts: 15
6912     0

Are you able to set the content-type in your ASP.net call, it should be set to JSON format: "Content-Type: application/json". Also, make sure you are doing a POST vs. GET.  Were you able to run it against V1.2.1 - https://infoblox/wapi/v1.2.1/record:host?

Can you try it from CURL on the command line to verify it works and then we can dig into how to make it work in ASP.net?

Curl errors

MRojas
Techie
Posts: 4
6912     0
I tried running it from curl, and it gave me: { "Error": "AdmConProtoError: JSON Decoding: No JSON object could be decoded", "code": "Client.Ibap.Proto.JSONDecoding", "text": "JSON Decoding: No JSON object could be decoded" } curl: (3) [globbing] unmatched close brace/bracket in column 13 curl: (6) Could not resolve host: name curl: (3) [globbing] unmatched close brace/bracket in column 15

Fixed

MRojas
Techie
Posts: 4
6912     0

We got it figured out.  First, we upgraded to WAPI V1.4.  Then, we used the following code:

Dim objHTTP = CreateObject("MSXML2.serverXMLHTTP")

        Dim strEnvelope = "ipv4addr=" & TextBox2.Text & "&mac=" & TextBox1.Text & "&comment=" & TextBox3.Text & "&name=" & TextBox4.Text

        objHTTP.SetOption(2, 13056)
        objHTTP.Open("POST", ("https://infoblox/wapi/v1.4/fixedaddress"), False, strUsername, strPassword)

        objHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")

        objHTTP.send(strEnvelope)

        Label3.Text = objHTTP.responseText

if you want to create a

GHorne Community Manager
Community Manager
Posts: 254
6912     0

if you want to create a static ip, don't create a 'record:host', just create a 'fixedaddress' object.

you can do this with the v1.2 api, you don't need to use v1.4

if you set the mac address to '00:00:00:00:00:00', it will create a reservation.

Highlighted

Re: if you want to create a

berridgd
Techie
Posts: 11
6912     0

Thanks, this works great! Do you know how I can set the Unlimited Lease Time field on the reservation? When I retreive the object and try to update the 'never_ends' field I get the following error...

 

AdmConProtoError: Operation update not allowed for lease

Showing results for 
Search instead for 
Do you mean 

Recommended for You