Reply

wapi servicerestart error

sanjaya
Techie
Posts: 2
166     0

I am using wapi v2.3.1
I am having trouble sending this service restert if neede command

I am using python 3.5 and requests module

Please help

 

>>> rt=requests.post(url + 'grid/b25lLmNsdXN0ZXIkMASmiley Tongueicocelldhcp?_function=servicerestart',data={'mode':'GROUPED','services':'ALL','restart_option':'RESTART_IF_NEEDED'},auth=(id,password), verify=False)
>>> rt.text
'{ "Error": "AdmConProtoError: When sending FORM arguments no URI arguments can be set (FORM arguments: {\'services\': [\'ALL\'], \'restart_option\': [\'RESTART_IF_NEEDED\'], \'mode\': [\'GROUPED\']} URI arguments: {\'_function\': [\'servicerestart\']}), please pass all the arguments as FORM arguments.", \n "code": "Client.Ibap.Proto", \n "text": "When sending FORM arguments no URI arguments can be set (FORM arguments: {\'services\': [\'ALL\'], \'restart_option\': [\'RESTART_IF_NEEDED\'], \'mode\': [\'GROUPED\']} URI arguments: {\'_function\': [\'servicerestart\']}), please pass all the arguments as FORM arguments."\n}'

Re: wapi servicerestart error

Adviser
Posts: 84
167     0

Hi,

 

Could you please add the Content-Type headers and try your call again.

 

Here is a sample code that you can use. I've highlighted the text you need to add to your code.

import requests
requests.packages.urllib3.disable_warnings()  # Disable SSL warnings in requests #
url = "https://127.0.0.1/wapi/v2.10/grid/b25lLmNsdXN0ZXIkMA:picocelldhcp?_function=servicerestart"
payload = "{\"mode\":\"GROUPED\",\"services\":\"ALL\",\"restart_option\":\"RESTART_IF_NEEDED\"}"
headers = {'content-type': "application/json"}
response = requests.request("POST", url, auth=('admin', 'Infoblox'), data=payload, headers=headers, verify=False)
print(response.text)

Hope this works,

Krishna Vasudevan

Re: wapi servicerestart error

sanjaya
Techie
Posts: 2
167     0

 

Thank you Krishna

 

>>> print(response.text)

Version 2.10 not supported
>>>

 

So I tried with V2.3.1

 

'https://127.0.0.1/wapi/v2.3.1/grid/b25lLmNsdXN0ZXIkMASmiley Tongueicocelldhcp?_function=restartservices'

payload = "{\"mode\":\"GROUPED\",\"services\":\"ALL\",\"restart_option\":\"RESTART_IF_NEEDED\"}"

headers = {'content-type': "application/json"}

response = requests.request("POST", url, auth=('admin','infoblox'), data=payload, headers=headers, verify=False)

got this error

>>> print(response.text)
{ "Error": "AdmConProtoError: List value expected for field: services",
"code": "Client.Ibap.Proto",
"text": "List value expected for field: services"
}

Showing results for 
Search instead for 
Do you mean 

Recommended for You