Skip to content

Instantly share code, notes, and snippets.

@Coornail
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Coornail/634390ff0f7e5f7b1077 to your computer and use it in GitHub Desktop.
Save Coornail/634390ff0f7e5f7b1077 to your computer and use it in GitHub Desktop.
#!/bin/sh
USERNAME=''
PASSWORD=''
BUCKET=''
AUTH_RESPONSE=`curl -s -X POST "https://api.zenobase.com/oauth/token" -d "grant_type=password&username=${USERNAME}&password=${PASSWORD}"`
echo $AUTH_RESPONSE
TOKEN=`echo ${AUTH_RESPONSE} | json -a access_token` && echo "Got token: $TOKEN"
for i in $(cat Body\ measurements\ -\ Sheet1.csv| cut -d ',' -f5,1); do
DATE=`echo $i | cut -d ',' -f1`T20:00:00.000-02:00
WEIGHT=`echo $i | cut -d ',' -f2`
DATA="{
\"timestamp\" : \"${DATE}\",
\"weight\" : {
\"@value\" : ${WEIGHT},
\"unit\": \"kg\"
}
}"
echo "Uploading ${DATE}: ${WEIGHT}"
curl -i -X POST "https://api.zenobase.com/buckets/{$BUCKET}/" \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" \
-d "${DATA}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment