Join the Conversation

To sign in, use your existing MySonicWall account. To create a free MySonicWall account click "Register".

SonicWALL Gen6 and Gen7 API call differences?

So I have this great PowerShell script written that can create or delete address objects. It can also add objects to an object group. Unfortunately it seems to only work for Gen7 devices. Can someone give me a hand figuring out what the API differences are between Gen6 and Gen7 please? I can't find any resources that explain this. This link seems to only give the 7.0.1 information: https://sonicos-api.sonicwall.com/


When running the script against a Gen6 devices I am getting this error when attempting to delete an address object.

Script Command:

Invoke-RestMethod "https://$($IP)/api/sonicos/address-objects/ipv4/name/$name" -Method 'DELETE' -Headers $headers -Body $body -SkipCertificateCheck:$true

Error:

An error occurred while invoking the REST method:

Response status code does not indicate success: 405 (Method Not Allowed).


Also on Gen6, when running the command to add address objects to a group, I get this error.

Script command :

Invoke-RestMethod "https://$($IP)/api/sonicos/address-groups/ipv6/name/$($name)" -Method 'PATCH' -Headers $headers -Body $body -SkipCertificateCheck:$true

Error:

An error occurred while invoking the REST method:

Response status code does not indicate success: 405 (Method Not Allowed).

Category: Developer Hub
Reply

Best Answer

  • CORRECT ANSWER
    JaimeJaime SonicWall Employee
    Answer ✓

    Sorry for the delay. I see the issue now. The JSON includes the name of the group you are editing, but "name" isn't a valid command within the CLI level you are in for editing that IPv6 address group (because this object's name cannot be changed). With other objects, the "name" command is available so you won't see the issue with those. Just remove the name line from your JSON body.


    {
      "address_group": {
        "ipv6": {
          "address_object": {
            "ipv4": [
              {
                "name": "My Group Member"
              }
            ]
          }
        }
      }
    }
    

Answers

Sign In or Register to comment.