KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm new to web services and am trying to send the following JSON based request using a python script: http://myserver/emoncms2/api/post?apikey=xxxxxxxxxxxxx&json={power:290.4,temperature:19.4} If I paste the above into a browser, it works as expected. However, I am struggling to send the request from Python. The following is what I am trying: import json import urllib2 data = {'temperature':'24.3'} data_json = json.dumps(data) host = "http://myserver/emoncms2/api/post" req = urllib2.Request(host, 'GET', data_json, {'content-type': 'application/json'}) response_stream = urllib2.urlopen(req) json_response = response_stream.read() How do I add the apikey data into the request? Thank you!
Tags (comma-separated)
Save Edits
Cancel