Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

KeyError: 'User-Agent' #37

Open
chrismyers81 opened this issue Jul 19, 2014 · 1 comment
Open

KeyError: 'User-Agent' #37

chrismyers81 opened this issue Jul 19, 2014 · 1 comment

Comments

@chrismyers81
Copy link

Hi all,

When I try to connect to xively using Python, I get a KeyError; not sure what I'm doing wrong or what that means? :/ I'm running Python 2.7.3 on my new BeagleBone Black rev. C.

The code I'm trying to use to connect, following the rPI documentation (https://xively.com/dev/tutorials/pi/):

!/usr/bin/python

import datetime
import requests
import xively
FEED_ID = 'my_id'
API_KEY = 'my_key'
api = xively.XivelyAPIClient(API_KEY)

Traceback (most recent call last):
File "datalogger.xively", line 14, in
api = xively.XivelyAPIClient(API_KEY)
File "/usr/local/lib/python2.7/dist-packages/xively/api.py", line 45, in init
self.client = self.client_class(key, use_ssl=use_ssl, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/xively/client.py", line 64, in init
xively.version, self.headers['User-Agent'])
KeyError: 'User-Agent'

How can I get around this?

@chrismyers81
Copy link
Author

I've been doing some more research this evening, and it seems as if for some reason, my xively instance isn't getting a "User-Agent" string. I found that if I remove that part of the code in the client.py, it seems to work ok:

    self.headers['User-Agent'] = 'xively-python/{}'.format(
        xively.__version__)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant