[BUG] Azure API Management - validate-content

Siebe Verschaeve 246 Reputation points

Hi, During the switch in our project of backend validation to Azure API-Management JSON validate-content we encountered a bug. When the request body includes a datetime such as "timestamp":"2020-06-19T12:54:40.180Z" the trailing 0 milliseconds are being truncated/trimmed.

  • 2020-06-19T12:54:40.180Z becomes 2020-06-19T12:54:40.18Z
  • 2020-06-19T12:54:40.100Z becomes 2020-06-19T12:54:40.1Z
  • 2020-06-19T12:54:40.000Z becomes 2020-06-19T12:54:40Z

Our project applies a strict format yyyy-MM-dd'T'HH:mm:ss.SSS'Z' so none of our implementations expect missing milliseconds nor do our 3rd parties when we forward events (JSON payloads) Rewriting the body (set-body policy) with the following expression does not fix the DateTime parsing. I'm sure that there is DateTime parsing ongoing when the validate-content policy is executed. The parsing needs to be an option.

Can someone give me some insights either on how to resolve it or confirm this is an ongoing bug.

<set-header name="Content-Type" exists-action="override">  
<set-body>@{ var body = context.Request.Body.AsJObject(true,new JsonSerializerSettings() { DateParseHandling = DateParseHandling.None }); return JsonConvert.SerializeObject(body); }</set-body>  
<validate-content unspecified-content-type-action="prevent" max-size="128" size-exceeded-action="ignore" errors-variable-name="validname">  
    <content type="application/json" validate-as="json" action="prevent" />  


Out of scope: I'm sure that the same bug happens whenever you send JSON timestamps through an eventgrid. Thanks to all from the community for participating.

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,663 questions
Azure Event Grid
Azure Event Grid
An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
297 questions
{count} votes

Accepted answer
  1. MayankBargali-MSFT 67,081 Reputation points

    Product team have fixed the issue and this changes will be included in the next release, which will likely start rolling out in July and finish in late July or in August.

    Updated: The issue is fixed now.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful