Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Problem with encoded parameters

$
0
0

Could someone Please help.  I am trying to understand how to create a safe url by escaping characters.

I have created an API that accepts the following string -  SendEmailWithAttachment(string to, string subject, string name, [FromBodystring data)

This API is called via an Angular 2 app where the user can and should be able to type anything they want into the "subject" of the email.  The problem
 that I am having is when the user type any of these characters &, *, <, >, %, ?, ~ the url returns a 404 bad request.  Note: I have been encoding all
 of these characters using both javascripts 'encodeURIComponent() and a custom function that encodes the remain characters that encodeURIComponent()
 does not cover ie: ~, !, * (, ). 

After running the &, *, <, >, %, ?, ~ characters through the two functions, the string is encoded to %26%2A%3C%3E%25%3F%7E;  Yet when I use thisstring as part of my URL, the URL returns 404 bad request. 

This is the final string.

http://localhost:59703/api/Export/SendEmail/myemail@gmail.com/%26%2A%3C%3E%25%3F%7E/invoices

Any Help would be greatly appreciated to help my understand how this is done

Thank You


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>