tags:

views:

56

answers:

3

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?

+1  A: 

Encode the square brackets

[ == %5B
] == %5D
Phil Brown
+5  A: 

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().

Greg
A: 

If you're using PHP, try out htmlspecialchars. To decode use htmlspecialchars_decode.

Steve
I think Sharepoint rules out the use of PHP. In any case, for URLs, you would use urlencode / rawurlencode.
Phil Brown
I suppose he could be using PHP to do posts against a sharepoint server... but he doesn't say he his, so it seems unlikely. Rawurlencode is generally the best route to go.
El Yobo
Ooohh ok read the damn question Steve :) Thanks for the tips
Steve