Hi all,
Iam trying to post data using fetchurl and then use the request
method, i get an error with HTTP 405 code. Both get and post do not
work, but what works is if i hardcode the values in the URL like ?
myhost=cool, it works. Please suggest.
To post data: (y.py)
-------------------------------------------------------------------------------------
from google.appengine.api import urlfetch
from google.appengine.api import apiproxy_stub_map
from google.appengine.api import urlfetch_stub
import urllib
url = "
http://myurl/"
apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
apiproxy_stub_map.apiproxy.RegisterStub
('urlfetch',urlfetch_stub.URLFetchServiceStub())
form_fields = {
"myhost": "cool",
"mysubject": "aid",
"email_address": "
te...@testing.com"
}
form_data = urllib.urlencode(form_fields)
result = urlfetch.fetch(url=url,
payload=form_data,
method=urlfetch.POST,
headers={'Content-Type': 'application/x-www-
form-urlencoded'})
-------------------------------------------------------------------------------------
Read data after post (x.py)
-------------------------------------------------------------------------------------
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.api import mail
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
host = self.request.get("myhost")
subj = self.request.get("mysubject")
to_addr = '
te...@tet.com'
application = webapp.WSGIApplication(
[('/', MainPage)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()