I am working with SharePoint using http post request. My url contains '[' so I am getting some exception.
Does anybody knows how to send a Post or Get request if the url contains '[' or ']' character?
I am working with SharePoint using http post request. My url contains '[' so I am getting some exception.
Does anybody knows how to send a Post or Get request if the url contains '[' or ']' character?
Encode the brackets in the url so that [
becomes %5B
and ]
becomes %5D
.
HTML URL Encoding Reference
If you are generating the URL from (.NET) code, use HttpServerUtility.UrlEncode().
string encodedUrl = "http://example.com/awesome.aspx?title="
+ HttpServerUtility.UrlEncode("Super & Delicious Program [v1]");
// "http://example.com/awesome.aspx?title=Super+%26+Delicious+Program+%5Bv1%5D"
The (roughly) equivalent method in JavaScript would be escape().
If you're using PHP, try out htmlspecialchars. To decode use htmlspecialchars_decode.