AnsweredAssumed Answered

API and filters

Question asked by David Morris on Feb 17, 2017
Latest reply on Feb 17, 2017 by Pat Pawlowski

I'm struggling a bit with the API. I'm trying to return a filtered list of records. I've read numerous posts on the developers blog, stackexchange and here about using filters pver the last few days and I honestly thought I'd "got it". Can I heck as like get it to do what I want... I could be doing something quite silly though. I'd be grateful if someone could cast their eye over what I've done. For the record, I'm running 7.7.1.1 Pro on-site, mysql and apache.

$arguments = array(
   "fields" => $delivery_fields,
   "filter" => array(
   array(
      'container' => array(
            '$eq' => ''
         )
      )
   ),
   "max_num" => 5
);
print_r($arguments);
echo json_encode($arguments);

$url = $base_url . "/del_DeliveryNotes/filter" ;
$record = call($url, $oauth2_token_response->access_token, 'POST', $arguments);
print_r($record);

What I'm getting consistently is an error message back from the API: "Did not recognise the operand $eq" (I'm actually wanting to use $is_null, but the current version of the test script just happens to have $eq in it. It was doing the same with $is_null

 

I've just swapped to using API endpoint <module>/filter POST from <module> GET in case that made any difference, but it's exactly the same. The json looks ok comparing it with what I've seen elsewhere. Where am I going wrong?

 

TIA

Outcomes