VMware Networking Community
i1wan
Enthusiast
Enthusiast
Jump to solution

ISSUE: Can not create an (edge) Firewall rule with the REST API

Dear,

I am trying to create a simple and basic edge firewall rule with the use of REST API.

I am using the REST API guide as a reference on page 158.


edge-fw-rule.png

I am using the  following (simple) code in my REST API client (with the correct Content-Type (application/xml)):

<rule>

  <ruleTag></ruleTag>

  <name>edge5-rest-rule</name>

  <source>any</source>

  <destination>any</destination>

  <application>any</application>

  <matchTranslated>true</matchTranslated>

  <direction>in</direction>

  <action>deny</action>

  <enabled>false</enabled>

  <loggingEnabled>true</loggingEnabled>

  <description>rest-api-rule</description>

</rule>

The error message that I receive is the following:

<?xml version="1.0" encoding="UTF-8"?>

<error>

    <details>Invalid request. Could not find mapping for element rule.</details>

    <errorCode>223</errorCode>

</error>

The full screenshot of my REST API action is in the screenshot below:

full-request.png

Does anyone know what I am doing wrong here?

Thanks!

1 Solution

Accepted Solutions
larsonm
VMware Employee
VMware Employee
Jump to solution

Try this as the body...

<firewallRules>

<firewallRule>

<name>rest-rule</name>

<ruleType>user</ruleType>

<matchTranslated>true</matchTranslated>

<direction>in</direction>

<action>deny</action>

<enabled>false</enabled>

<loggingEnabled>true</loggingEnabled>

<description>rest-api-rule</description>

</firewallRule>

</firewallRules>

View solution in original post

3 Replies
larsonm
VMware Employee
VMware Employee
Jump to solution

Try this as the body...

<firewallRules>

<firewallRule>

<name>rest-rule</name>

<ruleType>user</ruleType>

<matchTranslated>true</matchTranslated>

<direction>in</direction>

<action>deny</action>

<enabled>false</enabled>

<loggingEnabled>true</loggingEnabled>

<description>rest-api-rule</description>

</firewallRule>

</firewallRules>

i1wan
Enthusiast
Enthusiast
Jump to solution

Hey larsonm‌ thanks for your answer,

I indeed found out that the syntax that you are providing IS working.

I now wonder why the syntax in the "official" NSX REST API guide is not working / correct.

Reply
0 Kudos
Hamidreza74
Enthusiast
Enthusiast
Jump to solution

Hi 

I have this issue too
did you solve this issue?

Reply
0 Kudos