Click here to Skip to main content
15,665,444 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
We hosted a Web API to a customer. The customer send requests in which the + is included. Something like this:


Is there any solution to be able to change this plus signs to #2b in the request url? We just have control on API side, so could not encode the url from client side.

What I have tried:

Searched a lot but no explicit answer was found
Updated 13-Nov-20 2:09am
Richard MacCutchan 13-Nov-20 9:51am    
Why not just fix your API to accept the + sign?
Payman Biukaghazadeh 13-Nov-20 9:51am    

1 solution

If you don't control the client, then you can't change the client.

Why would you need to replace a perfectly valid querystring encoding with your invalid custom encoding? Everything after the first # is part of the fragment, not the querystring, and is not sent to the server.
Share this answer
Payman Biukaghazadeh 13-Nov-20 8:18am    
Because our API says:The query specified in the URI is not valid. The DateTimeOffset text '2020-09-28T00:00:00' should be in format 'yyyy-mm-ddThh:mm:ss('.'s+)?(zzzzzz)?' and each field value is within valid range
After we replace the + signs with %2b everything got ok. Here we could not change the url which client sends. We want to find a solution to be able to change the url on our side (web api)
Richard Deeming 13-Nov-20 8:22am    
%2b is different to what you said in your question: "change this plus signs to #2b".

%2b is a URL-encoded + sign. A + in the URL is an encoded space character. Neither of which is the format you've specified.

You need to tell your clients to properly encode their API calls.
Payman Biukaghazadeh 13-Nov-20 8:24am    
I could not change the client side. Because it was sent from Dynamics 365 virtual entities, and we do not have any control on the format of the url. So we need to be able to change the + to %2b
Richard Deeming 13-Nov-20 8:32am    
The URL from the client is invalid. If you cannot change the client, then you cannot fix the client. The client cannot call your API unless they properly encode the request parameters.
Payman Biukaghazadeh 13-Nov-20 9:50am    
I know this. But it could not be done. Is there any solution for API side? Such as IIS or in the API code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900