Issue with JSON input when it passes through Azure Gateway - Need help

jansi rani krishnan 601 Reputation points

I have a Microsoft Orchestrator Runbook web service which consumed by a third party application (Service Now). The Orchestrator Runbook accepts the input request as XML format as shown below.

<?xml version="1.0" encoding="utf-8" standalone="yes"?>  
<entry xmlns:d="" xmlns:m="" xmlns="">  
<content type="application/xml">  
<d:RunbookId type="Edm.Guid">{$($RunbookID)}</d:RunbookId>  

Since ServiceNow requested the input format in JSON, I converted the above XML based input to JSON format as below.

"RunbookId": "73aff8c3-1309-418a-bc8c-7eb22a6e41e7",   
"Parameters": "<Data>  
<Parameter><Name>Title</Name><ID>{a5017317-e6a6-4854-b106-bc12a30fa71b}</ID><Value>Test Incident</Value></Parameter>  
<Parameter><Name>Description</Name><ID>{4ffddad2-c2b2-44fa-b170-2a11ef7028c0}</ID><Value>This is created for testing purpose</Value></Parameter>  
<Parameter><Name>TierQueue</Name><ID>{aad4eefa-b0e5-4189-8791-48ead24c6098}</ID><Value>Support Infrastructure</Value></Parameter>  

We have the Azure Gateway in between ServiceNow and Orchestrator. When JSON request sent through Azure Gateway, it throws below error. Looks like JSON request is not in the required format when the Azure Gateway tries to parses the JSON input.

JSON parsing error: lexical error: invalid character inside string.  
Access denied with code 400 (phase 2). Match of "eq 0" against "REQBODY_ERROR" required.  

I need some input on how to make the JSON request a valid one, so that it can be parsed by Azure Gateway.
Your help is highly appreciated.


System Center Orchestrator
System Center Orchestrator
A family of System Center products that provide an automation platform for orchestrating and integrating both Microsoft and non-Microsoft IT tools.
218 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SaiKishor-MSFT 17,216 Reputation points

    @jansi rani krishnan Thank you for reaching out to Microsoft Q&A. I understand that you are having issues with Azure App GW throwing the above error when making the JSON request as explained above.

    In order to work around this, you either have to fix the validation error in your application or disable body inspection in App GW. Here is how to disable body inspection:

    To disable request body check via AZ PS:

    New-AzApplicationGatewayFirewallPolicySetting (Az.Network)


    [-Mode <String>]
    [-State <String>]
    [-MaxRequestBodySizeInKb <Int32>]
    [-MaxFileUploadInMb <Int32>]
    [-DefaultProfile <IAzureContextContainer>]

    $condition = New-AzApplicationGatewayFirewallPolicySetting -State $enabledState -Mode $enabledMode -DisableRequestBodyCheck -MaxFileUploadInMb $fileUploadLimitInMb -MaxRequestBodySizeInKb $maxRequestBodySizeInKb

    The new policySettings is stored to $condition.

    Then you set the FW WAF policy to use the policy setting above; reference: Set-AzApplicationGatewayFirewallPolicy (Az.Network)

    IN other words; in your script, you set the below:

    $policySetting = New-AzApplicationGatewayFirewallPolicySetting -Mode Prevention -State Enabled

    You need to add new switch: -DisableRequestBodyCheck with no value:

    $policySetting = New-AzApplicationGatewayFirewallPolicySetting -Mode Prevention -State Enabled -DisableRequestBodyCheck

    Reference: New-AzApplicationGatewayFirewallPolicySetting (Az.Network)

    If using AZ CLI, you can use the following command:

    az network application-gateway waf-config

    az network application-gateway waf-config set --enabled {false, true}
    [--firewall-mode {Detection, Prevention}]
    [--request-body-check {false, true}]

    Please let us know if you have any further questions and we will be glad to assist you further. Thank you!


    Hope this helps. Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.

    Want a reminder to come back and check responses? Here is how to subscribe to a notification.

    0 comments No comments