M2X Data Service - running m2x client - getting KeyError: 'device_id'

Re: running m2x client - getting KeyError: 'device_id'
03.01.2017 12:00 PM
test
Re: running m2x client - getting KeyError: 'device_id'
03.02.2017 04:26 AM
test
Re: running m2x client - getting KeyError: 'device_id'
03.02.2017 07:10 AM
test
Re: running m2x client - getting KeyError: 'device_id'
04.04.2017 09:39 AM
test
Re: running m2x client - getting KeyError: 'device_id'
04.04.2017 03:36 PM
Hi,
I am ok now, I was failing to run my python script as a post fdir rhe shell.
Re: running m2x client - getting KeyError: 'device_id'
04.20.2017 11:29 AM
This is a test of website. You need to post the API keys  to the python script from the command line.

Title: Python Key error - it could be versioning

 

In Python on a Raspberry pi model 3, I am receiving a Key error ? It could be versioning.
curl works great on the pi over wifi or AT&T LTE to the M2x cloud.

Here is the script output:

Python 2.7.9 (default, Sep 17 2016, 20:26:04) 

[GCC 4.9.2] on linux2

Type "copyright", "credits" or "license()" for more information.

>>> ================================ RESTART ================================

>>> 

 

Traceback (most recent call last):

  File "/home/pi/Desktop/GrovePi/Software/Python/att_IoT/m2x_example_search_devices.py", line 11, in <module>

    client = M2XClient(key=os.environ['MyrealAPIKey'])

  File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__

    raise KeyError(key)

KeyError: 'MyrealAPIKey'

>>>

Here is the m2x find devices example code:

#!/usr/bin/env python

# find devices for API key

# Usage:

#   $ API_KEY=<YOUR MASTER API KEY> python example.py

 

import os

 

from m2x.client import M2XClient

from m2x.v2.devices import Device

 

client = M2XClient(key=os.environ['MyrealAPIKey'])

 

params = {

"visibility": "private",

"status": "enabled",

"limit": "3"

}

 

response = Device.search(api = client, params = params)

if len(response) > 0:

    print("\nDevice Details :")

    for device in response:

        print("Device name: %s Device Id: %s Device Visibility: %s Device Status: %s " % (device.name, device.id, device.visibility, device.status ))

else:

    print("Devices not available in this search criteria")

This is a test of website. You need to post the API keys to the python script from the command line.