Q:

curl API calls with array of hashes

We are using a server software offering called FreezerPro (https://www.freezerpro.com/product-tour) with an API that can be called programmatically. There are simple methods like freezers that work with curl calls like this:
freezers -- Retrive a list of freezers
Returned objects: Freezers
Required parameters: None
Optional query parameters: None
Optional control parameters: None

curl -g --insecure 'https://username:password@demo-usa.freezerpro.com/api?method=freezers' | jq . | head -n 12
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  8697    0  8697    0     0  15980      0 --:--:-- --:--:-- --:--:-- 15987
{
  "Freezers": [
    {
      "rfid_tag": "355AB1CBC00000700000075A",
      "barcode_tag": "7000001882",
      "boxes": 0,
      "subdivisions": 1,
      "access": 0,
      "description": "[1000000000]",
      "name": "[1000000000]",
      "id": 1882
    },

Then there is a search_samples method that searches for any fields in samples given a query. E.g.:
search_samples -- search for samples:
Returned objects: Samples
Required parameters: None
Optional query parameters:
query = <filter text> optional search string to filter the results.
Optional control parameters:
start = <staring record>
limit = <limit number of records to retrieve>
sort = <sort_field>
dir = <ASC / DESC>

curl -g --insecure 'https://username:password@demo-usa.freezerpro.com/api?method=search_samples&query=111222333' | jq .                                                                      
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   347    0   347    0     0    977      0 --:--:-- --:--:-- --:--:--   977
{
  "Samples": [
    {
      "created_at": "06/11/2018",
      "owner_id": 45,
      "owner": "<span ext:qtip=\"username\">username</span>",
      "description": "test",
      "sample_id": 53087,
      "id": 53087,
      "loc_id": 54018,
      "type": "cfDNA",
      "scount": 1,
      "name": "123456AB",
      "location": "ER111&rarr;Level 1&rarr;Level 2&rarr;test001 (1)",
      "icon": "images/box40/i53.png"
    }
  ],
  "Total": 1
}

So far so good. The problem comes when trying to run the advanced_search query, which takes an array of hashes in the query section. Given the sample above, which has a udf called patient_id with value 111222333, and advanced_search query for udf patient_id value=111222333 should return something, but it just gives a blank result:

Example command:
curl -g --insecure 'https://username:password@demo-usa.freezerpro.com/api?method=advanced_search&subject_type=Sample&query=[{type="udf",field="patient_id",value=111222333}]'

I am using:
curl --version
curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp 
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP 

Is this something to do with the way curl works on interpreting/passing the query section of the URL?
Any ideas about how to construct the query? Is this a curl specific issue?
EDIT: tried curl urlencode, it complains about the query not being setup:
curl -g -G --insecure  'https://username:password@demo-usa.freezerpro.com/api' --data-urlencode 'method=advanced_search' --data-urlencode 'query=[{type="udf",field="patient_id",value=111222333}]'
{"error":true,"message":"Query or search conditions must be specified","success":false}

A:

I've found a solution using the --data flag together with the -k flag:
curl -k --header "Content-Type: application/json" --request GET --data '{"username":"user", "password":"password", "method":"advanced_search", "query":[{"type":"udf","field":"patient_id","op":"eq","value":"111222333"}], "udfs":["patient_id","other"]}' https://demo-usa.freezerpro.com/api | jq .

