0

I need to filter data from a search, but when passing a string to the refinementfilter an error occurs.

Microsoft.SharePoint.Client.InvalidClientQueryException

When I pass the parameters without the space character, for example, the query returns the results normally. However, when I pass the parameter with the space character the error occurs

My request:

$.ajax({
        type: "GET",
        dataType:"JSON",
        url: url + "/_api/search/query?querytext='teste'&startrow=0&rowlimit=100&selectproperties='Url,Title,Filename,AreaAtuacao,tipoConteudo,Created,ContentType'&sourceid='e1327b9c-2b8c-4b23-99c9-3730cb29c3f7'&refinementfilters='and(SPContentType:equals('Publicação'),AreaAtuacao:('Institucional'),TipoConteudo:('Artigos'))'",
            headers: {
            Accept: "application/json;odata=verbose",
            "X-RequestDigest": $('#__REQUESTDIGEST').val()
        },
            success: function (dados) {
                console.log(dados);
            },
        });

1 Answer 1

0

You will need to URL encode your string in order to use it in your AJAX request. To encode the value in JavaScript, you can use encodeURIComponent()

1
  • give me a example? Commented Jul 16, 2020 at 5:12

Your Answer

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

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