Thanks Massimo! It worked. request.body.read() had the JSON. On Thursday, August 9, 2012 9:42:05 AM UTC+8, Massimo Di Pierro wrote: > > There is nothing in request.args because I assume the URL is called > without args. > There is nothing in request.vars because the request contains no HTTP > variables. It is an HTTP post with a json data in the request body. HTTP > does not know anything about json. Web2py has no clue or way to guess the > request body contains json. It may as well be gibberish. Whoever created > the protocol should have used a mime multipart content (which is how forms > are submitted). > > Anyway, you can still email yourself: > > request.env # the headers > > and > > request.body.read() # the content of the body > > and you will get what you want. > > > > > On Wednesday, 8 August 2012 19:55:49 UTC-5, Osman Masood wrote: >> >> Hi all, >> I'm trying to confirm an Amazon SNS subscription with a web2py controller >> action. The Amazon SNS subscription format is described >> here<http://docs.amazonwebservices.com/sns/latest/gsg/SendMessageToHttp.html#SendMessageToHttp.confirm> >> (through >> probably not necessary to understand this problem.) >> >> My controller action (default/amazon_sns_endpoint) basically just emails >> request.vars and request.args to myself. It receives a POST request from >> the subscription service. However, for some reason, it doesn't seem to be >> able to process the POST request, i.e. request.vars and request.args are >> always {} and []. (I do, however, get the email.) >> >> Maybe web2py messes up when it handles some of the headers? An example >> POST request looks like this: >> >> POST / HTTP/1.1 >> x-amz-sns-message-type: SubscriptionConfirmation >> x-amz-sns-message-id: 165545c9-2a5c-472c-8df2-7ff2be2b3b1b >> x-amz-sns-topic-arn: arn:aws:sns:us-east-1:123456789012:MyTopic >> x-amz-sns-subscription-arn: >> arn:aws:sns:us-east-1:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55 >> Content-Length: 1336 >> Content-Type: text/plain; charset=UTF-8 >> Host: example.com >> Connection: Keep-Alive >> User-Agent: Amazon Simple Notification Service Agent >> >> { >> "Type" : "SubscriptionConfirmation", >> "MessageId" : "165545c9-2a5c-472c-8df2-7ff2be2b3b1b", >> "Token" : >> "2336412f37fb687f5d51e6e241d09c805a5a57b30d712f794cc5f6a988666d92768dd60a747ba6f3beb71854e285d6ad02428b09ceece29417f1f02d609c582afbacc99c583a916b9981dd2728f4ae6fdb82efd087cc3b7849e05798d2d2785c03b0879594eeac82c01f235d0e717736", >> "TopicArn" : "arn:aws:sns:us-east-1:123456789012:MyTopic", >> "Message" : "You have chosen to subscribe to the topic >> arn:aws:sns:us-east-1:123456789012:MyTopic.\nTo confirm the subscription, >> visit the SubscribeURL included in this message.", >> "SubscribeURL" : >> "https://sns.us-east-1.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-east-1:123456789012:MyTopic&Token=2336412f37fb687f5d51e6e241d09c805a5a57b30d712f794cc5f6a988666d92768dd60a747ba6f3beb71854e285d6ad02428b09ceece29417f1f02d609c582afbacc99c583a916b9981dd2728f4ae6fdb82efd087cc3b7849e05798d2d2785c03b0879594eeac82c01f235d0e717736", >> "Timestamp" : "2012-04-26T20:45:04.751Z", >> "SignatureVersion" : "1", >> "Signature" : >> "skvXQIEpH+DcEwjAPg8O9mY8dReBSwksfg2S7WKQcikcNKWLQjwu6A4VbeS0QHVCkhRS7fUQvi2egU3N858fiTDN6bkkOxYDVrY0Ad8L10Hs3zH81mtnPk5uvvolIC1CXGu43obcgFxeL3khZl8IKvO61GWB6jI9b5+gLPoBc1Q=", >> "SigningCertURL" : >> "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem" >> } >> >>
--

