Thanks for the tip.

I've done some tests, and I've found some details that could point the 
problem.

I'm sending a test post to my app url, from SparkPost web app. 
SparkPost tells me that it will send this post:

POST /ws/sparkpost_message_opened HTTP/1.1
Host: xxxxxxxxx.com.ar
Content-Type: application/json
X-MessageSystems-Batch-ID: 77c2b630-d712-11e4-9642-efc2723b99c1
Connection: close

[
  {
    "msys": {
      "track_event": {
        "type": "open",
        "campaign_id": "Example Campaign Name",
        "customer_id": "1",
        "delv_method": "esmtp",
        "event_id": "92356927693813856",
        "ip_address": "127.0.0.1",
        "message_id": "0e0d94b7-9085-4e3c-ab30-e3f2cd9c273e",
        "rcpt_meta": {
          "customKey": "customValue"
        },
        "rcpt_tags": [
          "male",
          "US"
        ],
        "rcpt_to": "[email protected]",
        "raw_rcpt_to": "[email protected]",
        "rcpt_type": "cc",
        "subaccount_id": "101",
        "template_id": "templ-1234",
        "template_version": "1",
        "timestamp": 1454442600,
        "transmission_id": "65832150921904138",
        "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36",
        "geo_ip": {
          "country": "US",
          "region": "MD",
          "city": "Columbia",
          "latitude": "39.1749",
          "longitude": "-76.8375"
        }
      }
    }
  }
]


I've modified my nginx log configuration, to log the $request_body to a log 
file, and I can see in deed the post (sorry about the format, but you can 
see the post data is there):

[{\x22msys\x22:{\x22track_event\x22:{\x22type\x22:\x22open\x22,\
x22campaign_id\x22:\x22Example Campaign Name\x22,\x22customer_id\x22:\x221\
x22,\x22delv_method\x22:\x22esmtp\x22,\x22event_id\x22:\x2292356927693813856
\x22,\x22ip_address\x22:\x22127.0.0.1\x22,\x22message_id\x22:\x220e0d94b7-
9085-4e3c-ab30-e3f2cd9c273e\x22,\x22rcpt_meta\x22:{\x22customKey\x22:\
x22customValue\x22},\x22rcpt_tags\x22:[\x22male\x22,\x22US\x22],\x22rcpt_to\
x22:\[email protected]\x22,\x22raw_rcpt_to\x22:\x22recipient@example.
com\x22,\x22rcpt_type\x22:\x22cc\x22,\x22subaccount_id\x22:\x22101\x22,\
x22template_id\x22:\x22templ-1234\x22,\x22template_version\x22:\x221\x22,\
x22timestamp\x22:1454442600,\x22transmission_id\x22:\x2265832150921904138\
x22,\x22user_agent\x22:\x22Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36\
x22,\x22geo_ip\x22:{\x22country\x22:\x22US\x22,\x22region\x22:\x22MD\x22,\
x22city\x22:\x22Columbia\x22,\x22latitude\x22:\x2239.1749\x22,\x22longitude\
x22:\x22-76.8375\x22}}}}]


However, in my controller, checking for request.post_vars returns False.
What am I missing?




El lunes, 7 de marzo de 2016, 13:19:17 (UTC-3), Anthony escribió:
>
> request.vars, request.post_vars, and request.get_vars are properties (and 
> their values are filled in lazily upon first access), so they are ignored 
> by BEAUTIFY (which only includes attributes found in request.keys()). If 
> you want the entire request object, you could try the trick used in 
> response.toolbar:
>
>     request.post_vars = request.post_vars
>     archivo.write(BEAUTIFY(request).xml())
>
> That will retrieve the post_vars and change request.post_vars to an 
> attribute, which BEAUTIFY will then display.
>
> Anthony
>
> On Monday, March 7, 2016 at 10:07:00 AM UTC-5, Lisandro wrote:
>>
>> I'm using SparkPost [1] (a transactional email platform) through its API 
>> [2].
>>
>> I'm trying to implement their webhook.
>> I have already set up a public URL in my app to let SparkPost send a POST 
>> each time a message is opened (that is, one of the messages I previously 
>> sent throug the API).
>>
>> The problem is that *I'm receiving the POST request, but nothing in 
>> post_vars, no vars, nothing*.
>> However, the headers do include some stuff that needs to be there, 
>> accordingly to SparkPost documentation [3].
>>
>>
>> My public function is really simple, just writes a BEAUTIFY(request) to a 
>> log file:
>>
>> def sparkpost_message_opened():
>>     archivo = open('webhook.log', 'a')
>>     archivo.write('------------------------------------\n')
>>     archivo.write(BEAUTIFY(request).xml())
>>     archivo.write('\n')
>>     archivo.close()
>>     return HTTP(200)
>>
>> However, when I check the received data, I see that the request object 
>> doesn't have post_vars or vars.
>> I think the problem could be in the SparkPost side, but I'm not sure.
>> How can I double check? Is there a way that I can see the post data that 
>> was sent? I'm using nginx.
>>
>>
>> [1] https://sparkpost.com
>> [2] https://developers.sparkpost.com/api/
>> [3] 
>> https://support.sparkpost.com/customer/en/portal/articles/2311698-comparing-webhook-and-message-event-data
>>
>>
>> Thanks in advance!
>> Regards, Lisandro. 
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to