chembl / chembl_webservices_2

Source code of the ChEMBL web services.
https://www.ebi.ac.uk/chembl/ws
Other
16 stars 3 forks source link

multiple params handles incorrectly when using JSON instead of x-www-form-urlencoded #145

Closed mnowotka closed 6 years ago

mnowotka commented 7 years ago

For example this works as expected (two icontains filters are chained together) and returns 254 results:

import requests
headers = {"X-HTTP-Method-Override": "GET"}
ret = requests.post('https://www.ebi.ac.uk/chembl/api/data/assay.json', data=[('assay_type', 'B'), ('description__icontains', 'insulin'), ('description__icontains', 'inhibition'), ('limit', 20), ('offset', 0)], headers=headers)

While this returns 148149 and the second filter overwrites the first one:

import requests
headers = {"X-HTTP-Method-Override": "GET", 'Content-type': 'application/json'}
ret = requests.post('https://www.ebi.ac.uk/chembl/api/data/assay.json', json=[('assay_type', 'B'), ('description__icontains', 'insulin'), ('description__icontains', 'inhibition'), ('limit', 20), ('offset', 0)], headers=headers)

On both cases HTTP contains enough information to make filter chain:

'assay_type=B&description__icontains=insulin&description__icontains=inhibition&limit=20&offset=0'

b'[["assay_type", "B"], ["description__icontains", "insulin"], ["description__icontains", "inhibition"], ["limit", 20], ["offset", 0]]'

So this is down to the API.

mnowotka commented 6 years ago

Fixed.