API Management Standard v2 decodes %2F in URL path before routing – classic (Developer) tier preserves it. By design?

Jan Claes 105 Reputation points
2026-10-22T13:22:56.32+00:00

We observe a behavioral difference between the classic and v2 API Management gateways when the request path contains percent-encoded slashes (%2F), and we would like to understand whether this is by design.

Setup

  • Environment A: API Management Developer tier (classic, stv2)
  • Environment B: API Management Standard v2
  • Both are fronted by Azure Application Gateway (WAF_v2) and receive traffic through private networking.
  • Identical API definition in both environments. Original operation URL template: GET /asset/{folderPath}/{assetName}

Request

GET https://api.contoso.com/document-management/v1/asset/folder1%2Fsub1%2Fsub2/file.html

Observed behavior

  • Developer tier (classic): APIM receives the path with %2F intact (visible in Application Insights request URL). The operation matches with folderPath = "folder1/sub1/sub2" and assetName = "file.html".
  • Standard v2: APIM receives/logs the path already decoded: /asset/folder1/sub1/sub2/file.html The path now has 4 segments, so the {folderPath}/{assetName} template no longer matches as intended.

What we ruled out

  • Application Gateway: the gateway logs (originalRequestUriWithArgs_s) show %2F is forwarded intact in both environments.
  • Cross-environment tests: routing the same Application Gateway to the other APIM instance shows the behavior follows the APIM instance, not the gateway:
    • Gateway A -> APIM Developer: %2F preserved
    • Gateway B -> APIM Developer: %2F preserved
    • Gateway A -> APIM Standard v2: decoded
    • Gateway B -> APIM Standard v2: decoded
  • Azure Firewall in the path operates at L4 only.
  • Policies (rewrite-uri, expressions on context.Request.OriginalUrl) cannot recover the encoded value; the decoding happens before policy execution.

Current mitigation

We changed the operation template to a wildcard (/asset/{*filePath}), which works on both tiers.

Questions

  1. Is normalization/decoding of %2F in the URL path before routing expected (by design) behavior of the v2 gateway (Basic v2 / Standard v2 / Premium v2)?
  2. Why does this differ from the classic gateway (Developer / Basic / Standard / Premium), which preserves %2F?
  3. Is there any configuration option (instance-level or via support) to preserve encoded slashes in the path on v2 tiers, or is this on the roadmap?
  4. Can this difference be added to the documentation that compares classic and v2 gateways (https://learn.microsoft.com/azure/api-management/api-management-gateways-overview)? It currently does not mention path normalization, which makes it easy to miss during a migration from classic to v2.

Related thread (same behavior reported on Consumption tier):

https://learn.microsoft.com/en-us/answers/questions/2281087/url-encoding-issue-in-azure-api-management-encoded

Thank you.

Azure API Management
Azure API Management

An Azure service that provides a hybrid, multi-cloud management platform for APIs.

0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-10-22T13:24:14.2966667+00:00

    For Standard v2, treat %2F as decoded before operation matching and keep the wildcard route (or move the slash-containing value out of the path), because no APIM policy or documented instance setting can preserve the original encoded slash at that stage.^1^

    What can be concluded

    • Standard v2: The behavior you reproduced is consistent with the published Microsoft Q&A guidance: %2F is decoded during path handling, before policies can restore it, and there is no built-in configuration for preserving encoded slashes in path parameters.^1^
    • Consumption: The same behavior is independently reported and accepted as non-configurable through policies.^2^
    • Basic v2 and Premium v2: The available public material does not explicitly establish a tier-wide contract for encoded-slash handling across every v2 SKU. Basic v2, Standard v2, and Premium v2 use the v2 gateway family, but the gateway comparison currently does not document %2F normalization.^3^ Therefore, Standard v2’s observed behavior should not be presented as a guaranteed specification for Basic v2 or Premium v2 without confirmation from Azure Support.
    • Classic versus v2: Microsoft documents these as different managed gateway families built on different service architectures.^3^ It does not publicly document the implementation-level reason that classic preserves %2F in this case while Standard v2 normalizes it. Also, classic stv2 is unrelated to the v2 service tiers; stv2 is the compute-platform generation for classic tiers.^4^

    Your cross-routing tests already isolate APIM as the differentiator, so no further Application Gateway or firewall troubleshooting is indicated.

    Supported mitigations

    Your /asset/{*filePath} mitigation is appropriate across APIM tiers. APIM officially supports wildcard operations for arbitrary path values, although Microsoft cautions that broad wildcard operations can increase API security exposure.^5^

    Apply explicit validation after matching:

    1. Retain GET /asset/{*filePath}.
    2. Split the decoded value at the final / in the backend or a policy:
      • folderPath = folder1/sub1/sub2
      • assetName = file.html
    3. Reject empty paths, ./.. segments, unexpected extensions, and paths outside the permitted asset namespace.
    4. Ensure the wildcard operation does not unintentionally shadow more-specific operations.

    If the API contract can change, stronger long-term alternatives are:

    • Put folderPath in a query parameter.
    • Encode it using a slash-free representation such as Base64url, then decode and validate it in the backend.^2^
    • Model folders as repeated or separately named parameters instead of treating / as data.

    rewrite-uri cannot recover the wire representation once operation matching has received the normalized path. It can only construct a new backend URL from information still available at policy execution.^6^ The policy catalog likewise contains no “preserve encoded path separators” setting.^7^

    Configuration, support, and roadmap

    There is no publicly documented instance-level switch or support-enabled setting for preserving %2F on Standard v2. A support request is still appropriate to obtain:

    • confirmation for the exact region and gateway build;
    • an explicit answer for Basic v2 and Premium v2;
    • confirmation whether the behavior is a permanent compatibility constraint or a candidate product change.

    No public APIM release entry through the June 2026 release identifies encoded-slash preservation as a planned feature or delivered fix.^8^ Absence from public release notes is not a commitment that it will never change; it means there is currently no documented roadmap or ETA.

    Documentation request

    Submit feedback directly on the gateway comparison page using its Feedback control, categorizing it as a documentation omission and including:

    • classic Developer (stv2) versus Standard v2;
    • the exact request containing %2F;
    • the resulting operation-match difference;
    • confirmation that normalization precedes policy execution;
    • the wildcard workaround;
    • a request for a compatibility row covering path normalization and encoded separators.

    Microsoft Learn’s feedback system routes documentation feedback to the relevant content teams; some repositories also expose a GitHub issue option.^9^


    References

    1. URL Encoding Issue in Azure API Management - Encoded Forward Slash (%2F ...
    2. URL Encoding Issue in Azure API Management - Encoded Forward Slash (%2F) Getting Decoded Automatically - Microsoft Q&A
    3. API gateway in Azure API Management
    4. Azure API Management v2 tiers
    5. Manually add an API
    6. Rewrite URL
    7. Azure API Management Policy Reference | Microsoft Learn
    8. Releases: Azure/API-Management - GitHub
    9. Provide feedback for Microsoft Learn content
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.