0

I'm using Rest api, so I send a Request with URLs, my problem is when the user nome a folder with a name containing a space or special characters, it sends nothing. I used the following conversion, but it does not work:

string url = "http://localhost:8080/alfresco/service/set/folder/permission/?folderName="
             + folder
             + "&permi="
             + acces
             + "&username="
             + user
             + "&alf_ticket="
             + GetToken();

Uri url2 = new Uri(url);
Response.Write(url2);
1
  • 2
    Try to encode the value using Server.UrlEncode(user) Commented Jan 22, 2015 at 10:45

2 Answers 2

5

You have to URL encode the variables in order to make them safe. Use HttpUtility.UrlEncode.

string urlSafeFolder = HttpUtility.UrlEncode(folder);

Use that variable in your URL and you will be fine. (You will have to do this for every parameter you pass in!)

Sign up to request clarification or add additional context in comments.

2 Comments

it's work, thank you, this function remplace space by +, but my request don't work, my url is in this way <url>/set/folder/permission/?folderName={folderName}&amp;permi={permi?}&amp;username={username?}&amp;alfTicket={ticket?}</url>
Your comment is unclear. What the problem exactly? Maybe it is better to ask a new question with a clear problem statement and reproduction scenario.
0

When ever any user types in space or any special character in the url we need to encode it using UrlEncode method --

string urlSafeFolder = HttpUtility.UrlEncode(folder);

So if a space is present inside url it will be converted to %20 and so on. For complete reference check http://www.w3schools.com/tags/ref_urlencode.asp

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.