Is it possible to download using API and get the json results in a compressed file?
Thanks,
Raffy
Is it possible to download using API and get the json results in a compressed file?
Thanks,
Raffy
@raffy_m, maybe this post discussed previously should help you solve your issue:
Hi @Kal_Lam ,
The quoted response does not answer my question which is how to get the results, when downloading using API. JSON which is compressed and not plain text. Thanks
Hi @raffy_m, you can look at the headers sent by the browser as it requests a compressed file and then deflates it. Here I’ve just copied the header 'Accept-Encoding: gzip, deflate, br'
:
TOKEN=your-secret-token
KF_URL=your-kf-url
ASSET_UID=your-asset-uid
curl -H "Authorization: Token $TOKEN" \
-H 'Accept-Encoding: gzip, deflate, br' \
-o data.gz \
"https://${KF_URL}/api/v2/assets/${ASSET_UID}/data.json"
ls -lah data.gz
-rw-r--r-- 1 josh staff 644B Jun 16 10:33 data.gz
Deflate the file:
gzip -dk data.gz
See the size difference of the deflated JSON data:
ls -lah data*
-rw-r--r-- 1 josh staff 2.1K Jun 16 10:39 data
-rw-r--r-- 1 josh staff 644B Jun 16 10:39 data.gz