THE GAME HAS CHANGED

Introducing Infoblox Universal DDI ManagementTM

Watch the launch to discover the new era of management for critical network services. Watch Now

API & Integration, DevOps,NetOps,SecOps

Reply

REST API - Creating a list of DNS host records using a signe HTTP connexion

New Member
Posts: 2
5566     0
I am currently creating DNS host records via REST API by writing requests on Python. Every POST request requires authentification, request headers and the host record data.

My question is: Is there a way to assign a list of records to the data field of the request to create multiple records with a single connection ? (Avoiding connection opening and closure on every request, and using only one for all)

Thank you,

C.B

Re: REST API - Creating a list of DNS host records using a signe HTTP connexion

[ Edited ]
Adviser
Posts: 181
5566     0

Hi,

 

You can use either of the following options:

  1. Import a CSV file that comtains the Host Records.
    This is covered in this document on page 89 (Import a CSV file)
  2. Using the Multiple Object Body function using the /request endpoint

    Operation

    REST Method

    API Call

    Sample Body

    Sample cURL Command

    Sample Output

    Create multiple host records

    POST

    <wapi_url>/request 

    [{"method": "POST",
       "object": "record:host",
       "data": {"name":"host-1.info.com",
                    "ipv4addrs": [{"ipv4addr":"10.10.10.21"}]},
       "assign_state": {"host1_ref": "_ref"},
       "enable_substitution": true,
        "discard": true},

      {"method": "POST",
       "object": "record:host",
       "data": {"name":"host-2.info.com",
                    "ipv4addrs": [{"ipv4addr":"10.10.10.22"}]},
       "assign_state": {"host2_ref": "_ref"},
       "enable_substitution": true,
        "discard": true},
      {"method": "STATE: DISPLAY"}]

    curl -k -u admin:Infoblox -H 'content-type:application/json' -X POST "https://grid-master/wapi/v2.10/request" -d '[{"method": "POST","object": "record:host","data": {"name":"host-1.info.com","ipv4addrs": [{"ipv4addr":"10.10.10.21"}]},"assign_state": {"host1_ref": "_ref"},"enable_substitution": true,"discard": true},{"method": "POST","object": "record:host","data": {"name":"host-2.info.com", "ipv4addrs": [{"ipv4addr":"10.10.10.22"}]},"assign_state": {"host2_ref": "_ref"},"enable_substitution": true,"discard": true},{"method": "STATE: DISPLAY"}]'

    [{"host1_ref": "record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5pbmZvLmhvc3QtMQ:host-1.info.com/default",
    "host2_ref": "record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5pbmZvLmhvc3QtMg:host-2.info.com/default"}]

Re: REST API - Creating a list of DNS host records using a signe HTTP connexion

New Member
Posts: 2
5566     0
Thank you @kvasudevan for your answer.
I will carry out this solution on my work.
Showing results for 
Search instead for 
Did you mean: 

Recommended for You