How to add IP to server using API

B3rt

Verified User
Joined
Oct 12, 2007
Messages
81
I want to add an (extra) IP to the server using the API but I cannot get this to work.

I use the following command as described at http://www.directadmin.com/features.php?id=673
/CMD_API_IP_MANAGER?action=add&ip=1.2.3.4&netmask=255.255.255.0
also tried:
/CMD_API_IP_MANAGER?action=add&add=Submit&ip=1.2.3.4&netmask=255.255.255.0&notify=no
ofcourse 1.2.3.4 is not the ip i wish to add...

I do this by using the API script from:
* @author Phi1 'l0rdphi1' Stier <[email protected]>
* @package HTTPSocket
* @version 2.6

When I change the value set_method( $method = 'GET' ) in to set_method( $method = 'POST' ) i get an error of Cannot redeclare class httpsocket

When I do this I get the results back of the IP's and resellers etc on the server but the IP is not added.
So the connection to the server works but the IP is not added.

What do I wrong here?
 
Hello,

When debugging API code, I find the best is to use this guide:
http://help.directadmin.com/item.php?id=293

Lower in the guide is an entry to grep out the string which tells you exactly what is being passed to DA.

Use this, and run one call with your browser to see what the browser is sending.
Then use your API right after to make the same call.

The data being passed should be the same (other than CMD_API_* vs CMD_*). The code that DA uses for both browser calls and API calls is exactly the same. The only difference is the output being generated, which is parseable.

With that, you'll very quickly be able to see what you're passing, and what the browser is passing and see the differences, to make the appropriate adjustments to your script.

John
 
Thx,

I found why the IP is not added.
In my terminal I see the output:
GET string: action=add&add=Submit&ip=1.2.3.4&netmask=255.255.255.0&status=free

I have no idea why it says it is a GET string, in the API script which I use I this to POST settings.
So something does not work here, is there maybe an other API script which work with POST and GET?
 
Back
Top