Skip to content

Error pushing values #15

Description

@sibero80

I have this very simple test script:

from ubidots import ApiClient
import subprocess, re, math, time

# Create an ApiClient object

api = ApiClient(token='####################')

# Get a Ubidots Variable

variable = api.get_variable('####################')

# Here is where you usually put the code to capture the data, either through yo$

count = 1

while(1):

    # Write the value to your variable in Ubidots
    count += 1
    aqi = 30
    print (count)
    print (aqi)
    response = variable.save_value({"value": aqi})
    #print(response)
    time.sleep(4)

But after 40 - 60 seconds of pushing data, I get this exception:

Traceback (most recent call last):
  File "ubi3.py", line 26, in <module>
    response = variable.save_value({"value": aqi})
  File "/usr/local/lib/python3.4/dist-packages/ubidots/apiclient.py", line 148, in wrapped_f
    return fn(self, *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/ubidots/apiclient.py", line 306, in save_value
    return self.bridge.post('variables/' + self.id + '/values', data).json()
  File "/usr/local/lib/python3.4/dist-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions