Search code examples
javascriptangularjsasp.net-web-apibackendbackand

HTTP 406 error server response: when sending filtering params in request


I have app in Backand that I'm building and I'm trying to use filter parameters. When calling my API using $http I get 406 error in the http request.

This would be the API call, passing the filter object:

function getUserAttractions(userId) {

  return $http({

    method: 'GET',

    url: Backand.getApiUrl() + '/1/objects/attractions',

    params: {

      sort: [{
        "fieldName": "date",
        "order": "asc"
      }],

      filter: [{
        "fieldName": "user_id",
        "operand": "contains",
        "value": "1"
      }]

    }

  });

}

Solution

  • First, you should use "operator" instead of "operand". If user_id is an object field then the filter should be:

    filter: [{"fieldName":"user_id","operator":"in","value":"1"}]
    

    here you can find additional documentation for other types of fields http://docs.backand.com/en/latest/apidocs/apidescription/index.html#rest-api-crud-operations

    Disclaimer: I work for Backand