Question/Issue: Error: Unexpected token I in JSON at position 14
Project ID: 135755
Context/Use case: I am using ECG data at 100Hz frequency and have built a custom data processing block. But I am getting this error: Error: Unexpected token I in JSON at position 14.
The code used to convert into JSOn is this:
for i in range(len(dataset)):
data = {
“protected”: {
“ver”: “v1”,
“alg”: “HS256”,
“iat”: time.time() # epoch time, seconds since 1970
},
“signature”: emptySignature,
“payload”: {
“device_name”: “72:20:B5:41:4A:3D:E8:11:A7:6A:FD:DF:7A:70:60:D0”,
“device_type”: “DATA_FORWARDER”,
“interval_ms”: 10,
“sensors”: [
{
“name”:“x”,
“units”:“N/A”
}
],
“values”:
dataset[i].tolist()
}
}
encoded = json.dumps(data)
signature = hmac.new(bytes(HMAC_KEY, 'utf-8'), msg = encoded.encode('utf-8'), digestmod = hashlib.sha256).hexdigest()
data['signature'] = signature
encoded = json.dumps(data)
res = requests.post(url='https://ingestion.edgeimpulse.com/api/training/data',
data=encoded,
headers={
'Content-Type': 'application/json',
'x-file-name': 'non_apneatic'+str(i),
'x-label': 'non_apneatic',
'x-api-key': API_KEY
})
if (res.status_code == 200):
print('Uploaded file to Edge Impulse', res.status_code, res.content)
else:
print('Failed to upload file to Edge Impulse', res.status_code, res.content)
Could someone please tell what is going wrong?