Create a HOST with PHP - cURL (WAPI)

Posts: 1
3149     0
Hi, I'm trying to create a host record with cURL (started from my php-page), and it looks like this: $ch = curl_init(); ... curl_setopt($ch, CURLOPT_USERPWD, "$acct:$passwd"); // username & pass (still default thou Smiley Happy ) curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "$httpmethod"); // $httplethod = "POST" curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // So I can decode the xml response curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); $curlcmd = $curl_base."record:host?ipv4addrs=(\"ipv4addr\"=\"\")&name=dummy.dummyzone"; // $curl_base contains my IP address of Infoblox curl_setopt($ch, CURLOPT_URL, $curlcmd); ... $response = CURL_EXEC($ch); Well, this gives me the following error: { "Error": "AdmConProtoError: List value expected for field: ipv4addrs", "code": "Client.Ibap.Proto", "text": "List value expected for field: ipv4addrs" } I tried every other way, ... with quotes, without quotes, escape characters, with brackets, without brackets, replaced the "=" with ":", etc ... But I cannot seem to get it right with that "ipv4addrS" field ... Always promps me for "a LIST" ... Where did I go wrong? Thanks in advance!

Hi Tom,

Posts: 9
3149     0

Hi Tom,

I came across this old post, and hope you didn't get discouraged!  Perhaps this example page for cURL host manipulation might help?

best regards, -Phil


Re: Create a HOST with PHP - cURL (WAPI)

GHorne Community Manager
Community Manager
Posts: 254
3149     0

Reformatting your query in {code} blocks helps.


When you are POSTing to the WAPI, you need to send JSON formatted data.

list values have to be in '[]' not '()'. and it is an array of objects, not just an array(list) of IP addresses. 


Also, since it is a POST, you can't put the values on the query string ( ?foo=bah ). they have to be in the body of the message.


the logical format would look like this:


 POST /wapi/v1.2/record:host
 Content-Type: application/json

    { "name":"",

If you are using cURL, that would be with a -X POST -d '{ "json" : "data" }'

Showing results for 
Search instead for 
Do you mean 

Recommended for You