Accepted Solution

store returned reference to a string

Posts: 2
153     0

Is it possible to store a returned reference to a string that can then be used in another command?


Basically what I'm looking to do is to get the reference for an a record and then use that reference to change the ip address using a script.


Re: store returned reference to a string

Posts: 96
153     0

Sure, like in this example. Any update you want to perform, first requires you to get the object db reference. You will need to add it to the URL:


First GET user Object _ref
        curl -k -u admin:infoblox -H "Content-Type: application/json" -X GET
    Use _ref to update the password:
        curl -k -u admin:infoblox -H "Content-Type: application/json" -X PUT -d '{"password": "infoblox2" }'



Now in a script, you can do the following (pseudo code):


my $json = from_json($client->responseContent());
   #print Dumper \$json;
   foreach my $item( @$json ) { 
      print "$item->{name}\n";
      # Modify Object
      my $ref = $item->{_ref};
      delete $item->{_ref};

      $item->{name} = "new-name";
      if ( restcall("PUT", "wapi/v2.5/$ref", $json_send->encode($item)) )
   	  print "Obj modified\n";

Re: store returned reference to a string

[ Edited ]
Posts: 101
153     0

Adding on to SSieber's approach, you can also use the Multiple Object Body Feature available with the /request object, which allows the control of WAPI through a single-entry point.

Multiple object body requests are composed of a list of single requests. While programming this enables to make multiple requests with one API call, thus simplifying an operation, and reducing the number of API calls to be made. In addition to the standard HTTP methods (GET, PUT, POST, and DELETE), single request inside a multiple object body request can be set to these values:




Copy fields in the data object to the state object.


Added the state object to the returned result list.

Note: The Multiple Object Body Feature is only available NIOS 7.1 onwards (WAPI v2.1 onwards)


To modify the IP address of an A record, you can use the following call (Replace the content highlighted in bold)

curl -k -u admin:infoblox -H 'content-type:application/json' -X POST "https://grid-master/wapi/v2.7/request" -d '[{"method": "STATE:ASSIGN","data":{"host_name":""}},{"method":"GET","object": "record:a","data": {"name":"##STATE:host_name:##"},"assign_state": {"host_ref": "_ref"},"enable_substitution": true,"discard": true},{ "method": "PUT", "object": "##STATE:host_ref:##","data": {"ipv4addr":""},"enable_substitution": true,"discard": true},{"method": "GET","object": "record:a","data": {"name":""}}]'



Re: store returned reference to a string

Posts: 30
153     0

Hi Kvasundevan,

In the above example, can I use multiple arguments like host_name and Ip_address and  and then the result should be satisfying both of the conditions.??

Re: store returned reference to a string

Posts: 30
154     0

Did you get the response for your query??


i.e using multiple parameters 

Showing results for 
Search instead for 
Do you mean 

Recommended for You