SSO Login is being implemented on this site. Existing users: Your existing password must be reset the first time you login using SSO. Click here to reset your password first before login. Your new username will be your email.

API & Integration, DevOps,NetOps,SecOps

Reply

Restarting Infoblox using API giving error

Techie
Posts: 7
279     0

Hi,

 

I am trying to restart Infoblox using API endpoint {restartservices} after fixing IP but I am getting an error [The remote server returned an error: (400) Bad Request.]

 

Any help would be greatly appriciated.

 

Thank you.

Re: Restarting Infoblox using API giving error

Authority
Posts: 16
279     0

Hi Sidko,

 

If you are trying to restart the grid you can append '_function=restartservices' to your api request

 

Below is a sample curl

curl -L -X POST 'https://<grid_ip>/wapi/v2.12/grid/<grid_ref>?_function=restartservices' -H 'Authorization: Basic YWRtaW46aW5mb2Jsb3g='

 

Regards,

Shukran

Re: Restarting Infoblox using API giving error

Techie
Posts: 7
279     0

Hi shukran,

Thank you for your reply.

I am using powershell

The url used

https://<IP>/wapi/v2.4/grid/<grid_ID>?_function=restartservices

 

I am able to raise other API request, I am only facing issue while restarting.

 

Regards,

Sidko

Re: Restarting Infoblox using API giving error

Authority
Posts: 16
279     0

Could you share the query you are trying to run in Powershell. Also could you try running it using some API client (like Postman or Insomnia)

Re: Restarting Infoblox using API giving error

Techie
Posts: 7
279     0

Hi shukran,

URL used: https://<IP>/wapi/v2.4/grid/<grid_ID>?_function=restartservices

 

$host_details = [ordered]@{
memberOrder="GROUPED"
requestType=“RESTART_IF_NEEDED"
serviceOption="ALL"
}


$body = $host_details | ConvertTo-Json
$response = Invoke-WebRequest -Uri $url -Method POST -Credential $creds -ContentType 'application/json' -Body $body -UseBasicParsing

 

Error:[The remote server returned an error: (400) Bad Request.]

 

I am able to run other API services using powershell its only giving me error while restarting it.

 

Regards,

Siddhant

 

Re: Restarting Infoblox using API giving error

Authority
Posts: 16
279     0

If you run the query using an API client does it go through?

Re: Restarting Infoblox using API giving error

Techie
Posts: 7
279     0

Its on clients onframe server I have tried postman on avalable brousers (firefox,IE) but looked like it didn't support these brousers.

Re: Restarting Infoblox using API giving error

Authority
Posts: 16
279     0

I think the issue may be because of the host details that you have entered.

member order and service option are deprecated and i have updated them with new parameters
also the request type option is not correct.

 

Could you use the below host details and try running it.

 

$host_details = [ordered]@{
mode="GROUPED"
restart_option="RESTART_IF_NEEDED"
services=@("ALL")
}

Re: Restarting Infoblox using API giving error

Community Manager
Community Manager
Posts: 162
279     0

Try this, for initiating the restart:

 

$niosip = "192.168.1.2"
$niosuser = "admin"
$niospw = "infoblox"
$wapiver = "v2.10"

$resturl = 'https://' + $niosip + '/wapi/' + $wapiver + '/request'

$resturl

$data = '
[
  {
    "method":"GET",
    "object":"grid",
    "assign_state": {"grid_ref": "_ref" },
    "enable_substitution": true
  },
  {
    "method":"POST",
    "object": "##STATE:grid_ref:##",
    "enable_substitution": true,
    "args":{"_function":"restartservices"},
    "data":{
      "mode":"GROUPED",
      "restart_option":"RESTART_IF_NEEDED"
    }
  }
]'

$json = $data | ConvertTo-Json

$json

$cred = New-Object PSCredential $niosuser, ($niospw | ConvertTo-SecureString -AsPlainText -Force)

add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    
    public class IDontCarePolicy : ICertificatePolicy {
        public IDontCarePolicy() {}
        public bool CheckValidationResult(
            ServicePoint sPoint, X509Certificate cert,
            WebRequest wRequest, int certProb) {
            return true;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy 

$out = Invoke-RestMethod -Uri $resturl -Method Post -Credential $cred -Body $data -ContentType 'application/json'

And try this to monitor the restart status of all the appliances:

 

$niosip = "192.168.1.2"
$niosuser = "admin"
$niospw = "infoblox"
$wapiver = "v2.10"

$resturl = 'https://' + $niosip + '/wapi/' + $wapiver + '/request'

$resturl

$data = '
[
  {
    "method":"GET",
    "object":"grid",
    "assign_state": {"grid_ref": "_ref" },
    "enable_substitution": true
  },
  {
    "method":"POST",
    "object": "##STATE:grid_ref:##",
    "enable_substitution": true,
    "args":{"_function":"restartservices"},
    "data":{
      "mode":"GROUPED",
      "restart_option":"RESTART_IF_NEEDED"
    }
  }
]'

$json = $data | ConvertTo-Json

$json

$cred = New-Object PSCredential $niosuser, ($niospw | ConvertTo-SecureString -AsPlainText -Force)

add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    
    public class IDontCarePolicy : ICertificatePolicy {
        public IDontCarePolicy() {}
        public bool CheckValidationResult(
            ServicePoint sPoint, X509Certificate cert,
            WebRequest wRequest, int certProb) {
            return true;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy 

$out = Invoke-RestMethod -Uri $resturl -Method Post -Credential $cred -Body $data -ContentType 'application/json'
Showing results for 
Search instead for 
Did you mean: 

Recommended for You