Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP trigger azure function won't bind route parameter with encoded slashes

I've created an Azure C# HTTP triggered function with a route url: subscriptions/{token}/t. It works fine for urls such as subscriptions/blah/t but it fails with a 404 for parameters that contain encoded slashes: subscriptions/blah%2fblah/t. Any way around this ?

Before we get into debates, {token} is a URL encoded Base64 string which will naturally contain slashes.

like image 836
marius-O Avatar asked Sep 16 '25 21:09

marius-O


1 Answers

This issue seems to persist. I found out that it can be resolved by double-escaping the string, that is, applying escaping recursively two times.

token = escape(escape(token));

In .NET you can use URI.EsacpeDataString()
In JS you can use encodeURIComponent()

Note, that single escaping does not work reliably with Azure functions

like image 55
Jan D. Avatar answered Sep 19 '25 11:09

Jan D.