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": "t...@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 = 't...@tet.com'

application = webapp.WSGIApplication(
                                     [('/', MainPage)],
                                     debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to