- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
wapi servicerestart error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2019 09:43 AM
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/b25lLmNsdXN0ZXIkMAicocelldhcp?_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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2019 11:35 PM
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2019 10:43 AM
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/b25lLmNsdXN0ZXIkMAicocelldhcp?_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"
}