Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

400 Bad Request when performing RangeFacetFor


Whenever I try to get a RangeFacet from Find, I'm getting a 400 Bad Request as response. My search is:

var prices = new List { new NumericRange(0, 500) };

var results = search.RangeFacetFor(x => x.SalePrice, prices.ToArray()).Take(0).GetResult();

If I remove the GetResult() I no longer get the error, but I have no clue why I do get it when I try and get the result.

Anyone have any advice?


Nov 19, 2015 12:00

What type are you seaching for? Can you show a little bit more of your code where the search variable is initialized?

Nov 23, 2015 9:17

Hi Mattias

  All I have so far is the below:

 var search = SearchClient.Instance.Search<BaseVariant>();

                search = filters.Aggregate(search, (current, filterBuilder) => current.Filter(filterBuilder));

                SearchResults<BaseVariant> results = null;

                var prices = new List<NumericRange> { new NumericRange(0, 500) };

                results = search.RangeFacetFor(x => x.SalePrice, prices.ToArray()).Take(0).GetResult();

The BaseVariant class has an extension method called SalePrice, which I ensure is indexed.


Nov 23, 2015 9:28

Calling GetResult() would execute your query towards FINDs REST service. If you remove GetResult, you only have a query that never is executed, hence the error/no error.

Your range facet looks correct, can you running GetResult without the filter (2nd line)?

What type is your SalePrice field?

Nov 23, 2015 9:38

Hi Mari

   Without the filter, it works.  Having added the filter back in, it still works!  Very strange, but it appears to work.



Nov 23, 2015 9:45

If BaseVariant is an EPiServer Content Type, try using GetContentResult instead of GetResult.

Edited, Nov 23, 2015 10:10
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.