I think the problem is that the server does not allow POST requests. You can probably try sending it in a GET request:
urllib2.urlopen("http://location/app/myroute/?" + jdata)
UPDATE :
I just realized by looking at your question again that you are actually trying to send JSON data via a GET request. You should generally avoid sending JSON with GET requests, but use POST [ Link ] requests instead.
To send a POST request to Bottle, you also need to set the headers in application/json :
headers = {} headers['Content-Type'] = 'application/json' jdata = json.dumps({"foo":"bar"}) urllib2.urlopen("http://location/app/myroute/", jdata, headers)
Then with @Anton's answer, you can access the JSON data in your view as follows:
@app.post('/myroute/') def myroute(): print request.json
Also, as a bonus, send a regular GET request and access it:
# send GET request urllib2.urlopen("http://location/app/myroute/?myvar=" + "test")
source share