Hello @Rishav Arora,
Thank you for the update, and we appreciate the steps you've taken to address the issue. Using Base64 URL-safe encoding on the client side and decoding it on the backend is a practical and commonly used workaround when dealing with reserved characters like forward slashes in API paths. Since Azure API Management automatically decodes characters like %2F
in the URL path, and this behavior can't be changed through policies, your approach helps avoid these issues without requiring changes to your existing API structure or client applications.Base64 URL encoding is safe for use in URLs because it avoids characters that can interfere with path parsing. It also ensures that the original value, including slashes, is preserved accurately. Just keep in mind that it will increase the length of the URL slightly, and the backend must correctly decode the values and handle any errors or invalid inputs gracefully. Also, make sure all your client applications use the same encoding format to avoid inconsistencies.
URL Encoding Issue in Azure API Management - Encoded Forward Slash (%2F) Getting Decoded Automatically
Rishav Arora
20
Reputation points
Description:
We are experiencing a URL encoding issue with Azure API Management where encoded forward slashes (%2F) in URL paths are being automatically decoded, causing routing problems.
Issue Details:
Expected Behavior:
- Frontend sends request to:
https://{base_url}/item/sb180d5e-ad82c28dc05b_12%2F27
- API Management should preserve the encoded format and pass the same URL structure to the backend
Actual Behavior:
- Frontend sends:
https://{base_url}/item/sb180d5e-ad82c28dc05b_12%2F27
- API Management automatically decodes %2F to / resulting in:
https://{base_url}/item/sb180d5e-ad82c28dc05b_12/27
- This creates incorrect path interpretation and routing failures
Impact:
- API calls fail due to incorrect path resolution
- Backend services cannot properly identify the intended resource
- URL parameters containing encoded forward slashes are not handled correctly
Environment:
- Azure API Management (Consumption tier)
- Frontend: (React)
Questions:
- Is there a configuration setting in APIM to preserve URL encoding for path parameters?
- Are there any policies that can prevent automatic URL decoding?
- What is the recommended approach for handling URLs with encoded forward slashes in APIM?
Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,446 questions
Accepted answer
-
Ranashekar Guda 2,820 Reputation points Microsoft External Staff Moderator
2025-06-09T16:44:32.2266667+00:00
1 additional answer
Sort by: Most helpful
-
Maxiem Wagenaar 0 Reputation points
2025-06-12T10:03:04.1566667+00:00 @Rishav Arora Have you tried using %252F instead of %2F? That was a simple solution that worked for us.