Reply
Highlighted
Accepted Solution

Create a new admin user via WAPI and cURL

[ Edited ]
basserado
Techie
Posts: 5
2273     0

Hi,

 

I´m trying to develop a webtool, which can be used by our customers to manage their infoblox systems. Currently I´m struggling with the user administration. I want to execute a curl command, which creates a new admin user.

 

My command look like this:

 

curl -k1 -u userSmiley Tongueassword -H 'Content-Type:application/json' -X POST https://123.123.123.123/wapi/v2.3.1/adminuser -d admin_groups=admin-group;name=testuser;password=test123

 

The error I´m getting is this one:


{ "Error": "AdmConProtoError: List value expected for field: admin_groups",
"code": "Client.Ibap.Proto",
"text": "List value expected for field: admin_groups"
}

 

So, the other two fields (name and password) work. Did anyone has a solution for me?

 

Thanks in advance for your help!

Re: Create a new admin user via WAPI and cURL

Adviser
Posts: 79
2274     0

Hello,

 

The admin_groups value specified should be a string array. Enclose the value within [].

 

Below is a sample curl command that you can use.

 curl -k -u admin:infoblox -H 'Content-Type:application/json' -X POST "https://grid-master/wapi/v2.3.1/adminuser?_return_fields%2B=admin_groups,name" -d '{"admin_groups":["admin-group"],"name":"testuser","password":"test123"}'

Hope this works for you,

Krishna Vasudevan

Re: Create a new admin user via WAPI and cURL

basserado
Techie
Posts: 5
2274     0

Thank you for your help. I tried that but got this error:

 

{ "Error": "AdmConProtoError: When sending FORM arguments no URI arguments can be set (FORM arguments: {\"'{admin_groups:[admin-group],name:testuser,password:test123}'\": ['']} URI arguments: {'_return_fields+': ['admin_groups,name']}), please pass all the arguments as FORM arguments.",
"code": "Client.Ibap.Proto",
"text": "When sending FORM arguments no URI arguments can be set (FORM argumen
ts: {\"'{admin_groups:[admin-group],name:testuser,password:test123}'\": ['']} URI arguments: {'_return_fields+': ['admin_groups,name']}), please pass all the arguments as FORM arguments."
}

 

I removed and attatched the URI arguments to the FORM arguments. Both ways didn´t work.

 

This is the error I get, if I remove the URI arguments completely:

 

{ "Error": "AdmConProtoError: Unknown argument/field: ''{admin_groups:[admin-group],name:testuser,password:test123}''",
"code": "Client.Ibap.Proto",
"text": "Unknown argument/field: ''{admin_groups:[admin-group],name:testuser,password:test123}''"
}

 

Are there any other possibilities?

Re: Create a new admin user via WAPI and cURL

Adviser
Posts: 79
2274     0

Hi,

 

Could you paste the exact command that you are executing?

 

Meanwhile, you can try running the following command (without the _return_fields argument):

 curl -k -u admin:infoblox -H 'Content-Type:application/json' -X POST "https://grid-master/wapi/v2.3.1/adminuser" -d '{"admin_groups":["admin-group"],"name":"testuser","password":"test123"}'

Re: Create a new admin user via WAPI and cURL

basserado
Techie
Posts: 5
2274     0

This is the command, which i executed in my post above:

 

curl -k -u admin:infoblox -H 'Content-Type:application/json' -X POST "https://grid-master/wapi/v2.3.1/adminuser" -d
{"admin_groups":["admin-group"],"name":"testuser","password":"test123"}

 

 

With your newest command I got this error:

 

{ "Error": "AdmConProtoError: Unknown argument/field: ''{admin_groups:[admin-gro

up],name:testuser,password:test123}''",
"code": "Client.Ibap.Proto",
"text": "Unknown argument/field: ''{admin_groups:[admin-group],name:testuser,p
assword:test123}''"
}

Re: Create a new admin user via WAPI and cURL

Adviser
Posts: 79
2274     0

Can you just modify your original command,i.e.

curl -k1 -u user:password -H 'Content-Type:application/json' -X POST https://123.123.123.123/wapi/v2.3.1/adminuser -d admin_groups=admin-group;name=testuser;password=test123

and add the '[]' around the "admin-group", like below.

curl -k1 -u user:password -H 'Content-Type:application/json' -X POST https://123.123.123.123/wapi/v2.3.1/adminuser -d admin_groups=[admin-group];name=testuser;password=test123

Re: Create a new admin user via WAPI and cURL

basserado
Techie
Posts: 5
2274     0

Got the same error with your latest command example:

 

{ "Error": "AdmConProtoError: List value expected for field: admin_groups",
"code": "Client.Ibap.Proto",
"text": "List value expected for field: admin_groups"
}

 

I tried so many commands with different syntax, that I´ve no idea whats to to next.

Re: Create a new admin user via WAPI and cURL

Adviser
Posts: 79
2274     0

Hi,

 

Looks like we were using different shells to execute the curl command. Please try the following command. It should work.

curl -k -u admin:infoblox -H "Content-Type:application/json" -X POST "https://grid-master/wapi/v2.3.1/adminuser" -d "{\"admin_groups\":[\"admin-group\"],\"name\":\"testuser\",\"password\":\"test123\"}"

Re: Create a new admin user via WAPI and cURL

basserado
Techie
Posts: 5
2274     0

Yes it worked. Thank you very much!

By the way, I used the normal "cmd"-shell from windows.

Showing results for 
Search instead for 
Do you mean 

Recommended for You