My scenario :

I am using a caml query to read all folder and files in a list but i noticed that if i get a folder by serverrelativeURl and the list name is(eg késhév,ie has special character or a space),the caml query return null.

For other list with standard name the codes work.

I am trying to use CDATA,but its not working.i think its a syntax error.

 var query = new CamlQuery();

            query.FolderServerRelativeUrl = folderServerRelativeUrl;

            query.ViewXml = "<View Scope=\"RecursiveAll\"> " +
                "<Query>" +
                "<Where>" +
                            "<Eq>" +
                                "<FieldRef Name=\"FileDirRef\" />" +
                                "<Value Type=\"Text\">" + "<![CDATA["+folderServerRelativeUrl+"]]>" + "</Value>" +
                             "</Eq>" +
                "</Where>" +
                "</Query>" +

            ListItemCollection folderItems = list.GetItems(query);
  • Try with the encoded value (k%C3%A9sh%C3%A9v). Mar 16 '18 at 7:37

Encode the values:

encodeURIComponent('listname') in javascript
Uri.EscapeUriString("listname") in C#
  • I am using c# and not javascript. Is there an equivalent Mar 18 '18 at 11:03
  • Use Uri.EscapeUriString("listname") in C#
    – Deepmala
    Mar 19 '18 at 3:32

Include the text containing special characters in CDATA. See this for reference: http://code2care.org/2015/error-caml-query-containing-special-characters/

  • Can you verify the code above please,i can't seem to be able to use a variable in CDATA Mar 18 '18 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.