Sending data to econcms2 via Python

Hi All,

I'm having problems sending data to my econcms2 server using python. It works fine if I send the post requests using the browser. The following is my python code:

#! /usr/bin/python

import sys
import json
import requests
my_config = {'verbose': sys.stdout}
data = {'temperature':'4.3'}
data_json = json.dumps(data)
payload = {'apikey': 'mykey', 'json': data_json}
r = requests.get('http://myserver/emoncms2/api/post', data=json.dumps(payload), config=my_config)
print r.status_code
print r.content

 

Any ideas why I keep getting "valid write apikey required"? Cheers, Donal

TrystanLea's picture

Re: Sending data to econcms2 via Python

Hello Donal

Im afraid Im not familiar with python so cant be of much help. Could you put the apikey in with the URL? 

http://myserver/emoncms2/api/post?apikey=mykey

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.