Introducing SOC Insights for BloxOne Threat Defense: Boost your SOC efficiency with AI-driven insights to eliminate manual work and accelerate investigation and response times. Read the blog announcement here.

API & Integration, DevOps,NetOps,SecOps

Reply

wapi servicerestart error

New Member
Posts: 3
3029     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: 181
3030     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

New Member
Posts: 3
3030     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 
Did you mean: 

Recommended for You