Pnpjs: Problem with char '&' in items.filter

Created on 30 Apr 2019  路  2Comments  路  Source: pnp/pnpjs

  • [ ] Enhancement
  • [ ] Bug
  • [x] Question
  • [ ] Documentation gap/issue

Hello. I am trying to send char & in filter

web.lists.getByTitle("XXXXX").items.filter("field1 eq 'test' and field2 eq 'te&st'").select("Title").get().then((itemsHR: any[]) => {

The problem that I get error

Uncaught (in promise) Error: Error making HttpClient request in queryable [400] ::> {"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The expression \"field1 eq 'test' and field2 eq 'te\" is not valid.

Thank you very much for your help.

code answered question

Most helpful comment

Hi @enti333,

Such special characters should be escaped. It's arguably should it be on the library's or custom app side. It's even more likely should not be in the library, as it is now. I'd recommend wrapping values through encodeURIComponent when you know that special symbols might be there.

All 2 comments

Hi @enti333,

Such special characters should be escaped. It's arguably should it be on the library's or custom app side. It's even more likely should not be in the library, as it is now. I'd recommend wrapping values through encodeURIComponent when you know that special symbols might be there.

Thank you Andrew. I was thinking if there is no better solution for this. But this is good enough. So Again Thank you very much.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pavan2920 picture pavan2920  路  3Comments

AJIXuMuK picture AJIXuMuK  路  3Comments

simonagren picture simonagren  路  3Comments

KieranDaviesV picture KieranDaviesV  路  3Comments

simkessy picture simkessy  路  3Comments