Solving JSON Array Issue in API

TLDR Martin shared a snippet of code. Hengfei indicated that the API required a JSON array, and suggested another API to use. Martin managed to fix their issue and thanked Hengfei for their help.

Photo of Martin
Martin
Tue, 12 Sep 2023 14:34:15 UTC

`json=$(top -bn1 | awk -F':' '/load average/ {print $4}' | awk -F', ' '{print "{\"cpu_load\":"$1"}"}' | sed 's/,/./g'); curl -u :s3cretP4ss -k -d $json`

Photo of Hengfei
Hengfei
Tue, 12 Sep 2023 14:41:17 UTC

Photo of Hengfei
Hengfei
Tue, 12 Sep 2023 14:41:24 UTC

this api needs a json array.

Photo of Hengfei
Hengfei
Tue, 12 Sep 2023 14:41:34 UTC

Photo of Hengfei
Hengfei
Tue, 12 Sep 2023 14:41:43 UTC

maybe you can try this api

Photo of Martin
Martin
Tue, 12 Sep 2023 14:44:33 UTC

Finally I fixed it. I didn't realized that an array was expected. Thanks for your help and patient with people that don't read documentations enough! :smile:

Photo of Martin
Martin
Tue, 12 Sep 2023 14:47:19 UTC

Finally got metrics loaded