Webhook data extract (JSON?)

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Webhook data extract (JSON?)

Laurent Gigon
Hi,

In order to remove hardbounced, I've created a webhook, which send
data to specific URL on my server. Raw data received on my server :

{"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":1507124995})

Then, I want to add those variables to my SQL database, but it does not work.

var('data_received')=Client_Params;
local('json') = var('data_received');

iterate(decode_json(#json), local('i'));

var('email') =  #i -> find('email');
var('event') =  #i -> find('event');
var('message-id') =  #i -> find('message-id');
var('type') =  #i  -> find('type');

 if( Valid_Email(var('email')) == True );

Inline( -Database='mydatabase',
-Table='hardbounced',
'email'=var('email'),
'event'=var('event'),
'message-id'=var('message-id'),
'type'=var('type'),
'date'=date_format(Server_Date, -format='%Q'),
-Add);

/Inline;

/if;

/iterate;

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Webhook data extract (JSON?)

stevepiercy
What specifically doesn't work?

What error messages, if any, are present?

Did you install the custom tag, client_params?
http://www.lassosoft.com/tagSwap/detail/client_params/

Sendgrid sends a lot more than just what you show in your "raw
data".  Please show the complete payload.

Suggest you insert log_critical statements to find out where it
goes wrong.

Suggested code improvements:

* Since this is a single file, use locals instead of vars.
* This is silly:

>var('data_received')=Client_Params;
>local('json') = var('data_received');

Do this in one step:

     local('json') = Client_Params;

--steve


On 10/4/17 at 10:11 AM, [hidden email] (Laurent G) pronounced:

>Hi,
>
>In order to remove hardbounced, I've created a webhook, which send
>data to specific URL on my server. Raw data received on my server :
>
>{"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
>15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":
>1507124995})
>
>Then, I want to add those variables to my SQL database, but it does not work.
>
>var('data_received')=Client_Params;
>local('json') = var('data_received');
>
>iterate(decode_json(#json), local('i'));
>
>var('email') =  #i -> find('email');
>var('event') =  #i -> find('event');
>var('message-id') =  #i -> find('message-id');
>var('type') =  #i  -> find('type');
>
>if( Valid_Email(var('email')) == True );
>
>Inline( -Database='mydatabase',
>-Table='hardbounced',
>'email'=var('email'),
>'event'=var('event'),
>'message-id'=var('message-id'),
>'type'=var('type'),
>'date'=date_format(Server_Date, -format='%Q'),
>-Add);
>
>/Inline;
>
>/if;
>
>/iterate;
>
>#############################################################
>
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Soquel, CA
<[hidden email]>               <http://www.stevepiercy.com/>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Webhook data extract (JSON?)

Laurent Gigon
This is sendinblue service, payload :
{"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":1507124995})

nothing logged.



2017-10-04 15:24 GMT-04:00 Steve Piercy - Website Builder <[hidden email]>:

> What specifically doesn't work?
>
> What error messages, if any, are present?
>
> Did you install the custom tag, client_params?
> http://www.lassosoft.com/tagSwap/detail/client_params/
>
> Sendgrid sends a lot more than just what you show in your "raw data".
> Please show the complete payload.
>
> Suggest you insert log_critical statements to find out where it goes wrong.
>
> Suggested code improvements:
>
> * Since this is a single file, use locals instead of vars.
> * This is silly:
>
>> var('data_received')=Client_Params;
>> local('json') = var('data_received');
>
>
> Do this in one step:
>
>     local('json') = Client_Params;
>
> --steve
>
>
> On 10/4/17 at 10:11 AM, [hidden email] (Laurent G) pronounced:
>
>> Hi,
>>
>> In order to remove hardbounced, I've created a webhook, which send
>> data to specific URL on my server. Raw data received on my server :
>>
>>
>> {"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
>>
>> 15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":
>> 1507124995})
>>
>> Then, I want to add those variables to my SQL database, but it does not
>> work.
>>
>> var('data_received')=Client_Params;
>> local('json') = var('data_received');
>>
>> iterate(decode_json(#json), local('i'));
>>
>> var('email') =  #i -> find('email');
>> var('event') =  #i -> find('event');
>> var('message-id') =  #i -> find('message-id');
>> var('type') =  #i  -> find('type');
>>
>> if( Valid_Email(var('email')) == True );
>>
>> Inline( -Database='mydatabase',
>> -Table='hardbounced',
>> 'email'=var('email'),
>> 'event'=var('event'),
>> 'message-id'=var('message-id'),
>> 'type'=var('type'),
>> 'date'=date_format(Server_Date, -format='%Q'),
>> -Add);
>>
>> /Inline;
>>
>> /if;
>>
>> /iterate;
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy              Website Builder              Soquel, CA
> <[hidden email]>               <http://www.stevepiercy.com/>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Webhook data extract (JSON?)

stevepiercy
Omitted questions, yadda yadda...

That payload looks incomplete or incorrect due to the trailing ")".

--steve


On 10/4/17 at 5:09 PM, [hidden email] (Laurent G) pronounced:

>This is sendinblue service, payload :
>{"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
>15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":
>1507124995})
>
>nothing logged.
>
>
>
>2017-10-04 15:24 GMT-04:00 Steve Piercy - Website Builder <[hidden email]>:
>>What specifically doesn't work?
>>
>>What error messages, if any, are present?
>>
>>Did you install the custom tag, client_params?
>>http://www.lassosoft.com/tagSwap/detail/client_params/
>>
>>Sendgrid sends a lot more than just what you show in your "raw data".
>>Please show the complete payload.
>>
>>Suggest you insert log_critical statements to find out where it goes wrong.
>>
>>Suggested code improvements:
>>
>>* Since this is a single file, use locals instead of vars.
>>* This is silly:
>>
>>> var('data_received')=Client_Params;
>>> local('json') = var('data_received');
>>
>>
>>Do this in one step:
>>
>>local('json') = Client_Params;
>>
>>--steve
>>
>>
>>On 10/4/17 at 10:11 AM, [hidden email] (Laurent G) pronounced:
>>
>>> Hi,
>>>
>>> In order to remove hardbounced, I've created a webhook, which send
>>> data to specific URL on my server. Raw data received on my server :
>>>
>>>
>>> {"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
>>>
>>>
>15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":
>>> 1507124995})
>>>
>>> Then, I want to add those variables to my SQL database, but it does not
>>> work.
>>>
>>> var('data_received')=Client_Params;
>>> local('json') = var('data_received');
>>>
>>> iterate(decode_json(#json), local('i'));
>>>
>>> var('email') =  #i -> find('email');
>>> var('event') =  #i -> find('event');
>>> var('message-id') =  #i -> find('message-id');
>>> var('type') =  #i  -> find('type');
>>>
>>> if( Valid_Email(var('email')) == True );
>>>
>>> Inline( -Database='mydatabase',
>>> -Table='hardbounced',
>>> 'email'=var('email'),
>>> 'event'=var('event'),
>>> 'message-id'=var('message-id'),
>>> 'type'=var('type'),
>>> 'date'=date_format(Server_Date, -format='%Q'),
>>> -Add);
>>>
>>> /Inline;
>>>
>>> /if;
>>>
>>> /iterate;
>>>
>>> #############################################################
>>>
>>> This message is sent to you because you are subscribed to
>>> the mailing list Lasso [hidden email]
>>> Official list archives available at http://www.lassotalk.com
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>
>>
>>-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>Steve Piercy              Website Builder              Soquel, CA
>><[hidden email]>               <http://www.stevepiercy.com/>
>>
>>
>>#############################################################
>>
>>This message is sent to you because you are subscribed to
>>the mailing list Lasso [hidden email]
>>Official list archives available at http://www.lassotalk.com
>>To unsubscribe, E-mail to: <[hidden email]>
>>Send administrative queries to  <[hidden email]>
>
>#############################################################
>
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Soquel, CA
<[hidden email]>               <http://www.stevepiercy.com/>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Webhook data extract (JSON?)

Laurent Gigon
I've installed client_params tag

The original payload is :

array: ({"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-05
16:25:26","ts":1507213526,"message-id":"<[hidden email]>","ts_event":1507213526})

how to insert "log_critical statements" because nothing is logged.


2017-10-04 18:23 GMT-04:00 Steve Piercy - Website Builder <[hidden email]>:

> Omitted questions, yadda yadda...
>
> That payload looks incomplete or incorrect due to the trailing ")".
>
> --steve
>
>
> On 10/4/17 at 5:09 PM, [hidden email] (Laurent G) pronounced:
>
>
>> This is sendinblue service, payload :
>>
>> {"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
>>
>> 15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":
>> 1507124995})
>>
>> nothing logged.
>>
>>
>>
>> 2017-10-04 15:24 GMT-04:00 Steve Piercy - Website Builder
>> <[hidden email]>:
>>>
>>> What specifically doesn't work?
>>>
>>> What error messages, if any, are present?
>>>
>>> Did you install the custom tag, client_params?
>>> http://www.lassosoft.com/tagSwap/detail/client_params/
>>>
>>> Sendgrid sends a lot more than just what you show in your "raw data".
>>> Please show the complete payload.
>>>
>>> Suggest you insert log_critical statements to find out where it goes
>>> wrong.
>>>
>>> Suggested code improvements:
>>>
>>> * Since this is a single file, use locals instead of vars.
>>> * This is silly:
>>>
>>>> var('data_received')=Client_Params;
>>>> local('json') = var('data_received');
>>>
>>>
>>>
>>> Do this in one step:
>>>
>>> local('json') = Client_Params;
>>>
>>> --steve
>>>
>>>
>>> On 10/4/17 at 10:11 AM, [hidden email] (Laurent G) pronounced:
>>>
>>>> Hi,
>>>>
>>>> In order to remove hardbounced, I've created a webhook, which send
>>>> data to specific URL on my server. Raw data received on my server :
>>>>
>>>>
>>>>
>>>> {"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
>>>>
>>>>
>>
>> 15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":
>>>>
>>>> 1507124995})
>>>>
>>>> Then, I want to add those variables to my SQL database, but it does not
>>>> work.
>>>>
>>>> var('data_received')=Client_Params;
>>>> local('json') = var('data_received');
>>>>
>>>> iterate(decode_json(#json), local('i'));
>>>>
>>>> var('email') =  #i -> find('email');
>>>> var('event') =  #i -> find('event');
>>>> var('message-id') =  #i -> find('message-id');
>>>> var('type') =  #i  -> find('type');
>>>>
>>>> if( Valid_Email(var('email')) == True );
>>>>
>>>> Inline( -Database='mydatabase',
>>>> -Table='hardbounced',
>>>> 'email'=var('email'),
>>>> 'event'=var('event'),
>>>> 'message-id'=var('message-id'),
>>>> 'type'=var('type'),
>>>> 'date'=date_format(Server_Date, -format='%Q'),
>>>> -Add);
>>>>
>>>> /Inline;
>>>>
>>>> /if;
>>>>
>>>> /iterate;
>>>>
>>>> #############################################################
>>>>
>>>> This message is sent to you because you are subscribed to
>>>> the mailing list Lasso [hidden email]
>>>> Official list archives available at http://www.lassotalk.com
>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>> Send administrative queries to  <[hidden email]>
>>>
>>>
>>>
>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>> Steve Piercy              Website Builder              Soquel, CA
>>> <[hidden email]>               <http://www.stevepiercy.com/>
>>>
>>>
>>> #############################################################
>>>
>>> This message is sent to you because you are subscribed to
>>> the mailing list Lasso [hidden email]
>>> Official list archives available at http://www.lassotalk.com
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy              Website Builder              Soquel, CA
> <[hidden email]>               <http://www.stevepiercy.com/>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Webhook data extract (JSON?)

stevepiercy
Effectively you are doing this:

     local('json') = array({"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-05
     16:25:26","ts":1507213526,"message-id":"<[hidden email]>","ts_event":1507213526});

     iterate(decode_json(#json), local('i'));

See what's wrong with that?

To fix, do this:

     if(#json -> size == 1);
         #json = #json -> get(1);
         #json = decode_json(#json);
     else;
         // handle error
     /if;

     if(valid_email(#json -> find('email')));
         inline(
             -database='mydatabase',
             -table='hardbounced',
             'email'=#json -> find('email'),
             'event'=#json -> find('event'),
             'message-id'=#json -> find('message-id'),
             'type'=#json -> find('type'),
             'date'=date_format(server_date, -format='%Q'),
             -add);
         /inline;
     else;
         // handle error
     /if;

--steve


On 10/5/17 at 10:29 AM, [hidden email] (Laurent G) pronounced:

>I've installed client_params tag
>
>The original payload is :
>
>array: ({"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-05
>16:25:26","ts":1507213526,"message-id":"<[hidden email]>","ts_event":
>1507213526})
>
>how to insert "log_critical statements" because nothing is logged.
>
>
>2017-10-04 18:23 GMT-04:00 Steve Piercy - Website Builder <[hidden email]>:
>>Omitted questions, yadda yadda...
>>
>>That payload looks incomplete or incorrect due to the trailing ")".
>>
>>--steve
>>
>>
>>On 10/4/17 at 5:09 PM, [hidden email] (Laurent G) pronounced:
>>
>>
>>> This is sendinblue service, payload :
>>>
>>> {"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
>>>
>>>
>15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":
>>> 1507124995})
>>>
>>> nothing logged.
>>>
>>>
>>>
>>> 2017-10-04 15:24 GMT-04:00 Steve Piercy - Website Builder
>>> <[hidden email]>:
>>>>
>>>> What specifically doesn't work?
>>>>
>>>> What error messages, if any, are present?
>>>>
>>>> Did you install the custom tag, client_params?
>>>> http://www.lassosoft.com/tagSwap/detail/client_params/
>>>>
>>>> Sendgrid sends a lot more than just what you show in your "raw data".
>>>> Please show the complete payload.
>>>>
>>>> Suggest you insert log_critical statements to find out where it goes
>>>> wrong.
>>>>
>>>> Suggested code improvements:
>>>>
>>>> * Since this is a single file, use locals instead of vars.
>>>> * This is silly:
>>>>
>>>>> var('data_received')=Client_Params;
>>>>> local('json') = var('data_received');
>>>>
>>>>
>>>>
>>>> Do this in one step:
>>>>
>>>> local('json') = Client_Params;
>>>>
>>>> --steve
>>>>
>>>>
>>>> On 10/4/17 at 10:11 AM, [hidden email] (Laurent G) pronounced:
>>>>
>>>>> Hi,
>>>>>
>>>>> In order to remove hardbounced, I've created a webhook, which send
>>>>> data to specific URL on my server. Raw data received on my server :
>>>>>
>>>>>
>>>>>
>>>>> {"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
>>>>>
>>>>>
>>>
>>>
>15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":
>>>>>
>>>>> 1507124995})
>>>>>
>>>>> Then, I want to add those variables to my SQL database, but it does not
>>>>> work.
>>>>>
>>>>> var('data_received')=Client_Params;
>>>>> local('json') = var('data_received');
>>>>>
>>>>> iterate(decode_json(#json), local('i'));
>>>>>
>>>>> var('email') =  #i -> find('email');
>>>>> var('event') =  #i -> find('event');
>>>>> var('message-id') =  #i -> find('message-id');
>>>>> var('type') =  #i  -> find('type');
>>>>>
>>>>> if( Valid_Email(var('email')) == True );
>>>>>
>>>>> Inline( -Database='mydatabase',
>>>>> -Table='hardbounced',
>>>>> 'email'=var('email'),
>>>>> 'event'=var('event'),
>>>>> 'message-id'=var('message-id'),
>>>>> 'type'=var('type'),
>>>>> 'date'=date_format(Server_Date, -format='%Q'),
>>>>> -Add);
>>>>>
>>>>> /Inline;
>>>>>
>>>>> /if;
>>>>>
>>>>> /iterate;
>>>>>
>>>>> #############################################################
>>>>>
>>>>> This message is sent to you because you are subscribed to
>>>>> the mailing list Lasso [hidden email]
>>>>> Official list archives available at http://www.lassotalk.com
>>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>>> Send administrative queries to  <[hidden email]>
>>>>
>>>>
>>>>
>>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>>> Steve Piercy              Website Builder              Soquel, CA
>>>> <[hidden email]>               <http://www.stevepiercy.com/>
>>>>
>>>>
>>>> #############################################################
>>>>
>>>> This message is sent to you because you are subscribed to
>>>> the mailing list Lasso [hidden email]
>>>> Official list archives available at http://www.lassotalk.com
>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>> Send administrative queries to  <[hidden email]>
>>>
>>>
>>> #############################################################
>>>
>>> This message is sent to you because you are subscribed to
>>> the mailing list Lasso [hidden email]
>>> Official list archives available at http://www.lassotalk.com
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>
>>
>>-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>Steve Piercy              Website Builder              Soquel, CA
>><[hidden email]>               <http://www.stevepiercy.com/>
>>
>>
>>#############################################################
>>
>>This message is sent to you because you are subscribed to
>>the mailing list Lasso [hidden email]
>>Official list archives available at http://www.lassotalk.com
>>To unsubscribe, E-mail to: <[hidden email]>
>>Send administrative queries to  <[hidden email]>
>
>#############################################################
>
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Soquel, CA
<[hidden email]>               <http://www.stevepiercy.com/>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Webhook data extract (JSON?)

Laurent Gigon
doesn't work, no error code :(


2017-10-05 12:26 GMT-04:00 Steve Piercy - Website Builder <[hidden email]>:

> Effectively you are doing this:
>
>     local('json') =
> array({"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-05
>
> 16:25:26","ts":1507213526,"message-id":"<[hidden email]>","ts_event":1507213526});
>
>     iterate(decode_json(#json), local('i'));
>
> See what's wrong with that?
>
> To fix, do this:
>
>     if(#json -> size == 1);
>         #json = #json -> get(1);
>         #json = decode_json(#json);
>     else;
>         // handle error
>     /if;
>
>     if(valid_email(#json -> find('email')));
>         inline(
>             -database='mydatabase',
>             -table='hardbounced',
>             'email'=#json -> find('email'),
>             'event'=#json -> find('event'),
>             'message-id'=#json -> find('message-id'),
>             'type'=#json -> find('type'),
>             'date'=date_format(server_date, -format='%Q'),
>             -add);
>         /inline;
>     else;
>         // handle error
>     /if;
>
> --steve
>
>
> On 10/5/17 at 10:29 AM, [hidden email] (Laurent G) pronounced:
>
>
>> I've installed client_params tag
>>
>> The original payload is :
>>
>> array:
>> ({"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-05
>>
>> 16:25:26","ts":1507213526,"message-id":"<[hidden email]>","ts_event":
>> 1507213526})
>>
>> how to insert "log_critical statements" because nothing is logged.
>>
>>
>> 2017-10-04 18:23 GMT-04:00 Steve Piercy - Website Builder
>> <[hidden email]>:
>>>
>>> Omitted questions, yadda yadda...
>>>
>>> That payload looks incomplete or incorrect due to the trailing ")".
>>>
>>> --steve
>>>
>>>
>>> On 10/4/17 at 5:09 PM, [hidden email] (Laurent G) pronounced:
>>>
>>>
>>>> This is sendinblue service, payload :
>>>>
>>>>
>>>> {"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
>>>>
>>>>
>>
>> 15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":
>>>>
>>>> 1507124995})
>>>>
>>>> nothing logged.
>>>>
>>>>
>>>>
>>>> 2017-10-04 15:24 GMT-04:00 Steve Piercy - Website Builder
>>>> <[hidden email]>:
>>>>>
>>>>>
>>>>> What specifically doesn't work?
>>>>>
>>>>> What error messages, if any, are present?
>>>>>
>>>>> Did you install the custom tag, client_params?
>>>>> http://www.lassosoft.com/tagSwap/detail/client_params/
>>>>>
>>>>> Sendgrid sends a lot more than just what you show in your "raw data".
>>>>> Please show the complete payload.
>>>>>
>>>>> Suggest you insert log_critical statements to find out where it goes
>>>>> wrong.
>>>>>
>>>>> Suggested code improvements:
>>>>>
>>>>> * Since this is a single file, use locals instead of vars.
>>>>> * This is silly:
>>>>>
>>>>>> var('data_received')=Client_Params;
>>>>>> local('json') = var('data_received');
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Do this in one step:
>>>>>
>>>>> local('json') = Client_Params;
>>>>>
>>>>> --steve
>>>>>
>>>>>
>>>>> On 10/4/17 at 10:11 AM, [hidden email] (Laurent G) pronounced:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> In order to remove hardbounced, I've created a webhook, which send
>>>>>> data to specific URL on my server. Raw data received on my server :
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> {"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
>>>>>>
>>>>>>
>>>>
>>>>
>>
>> 15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":
>>>>>>
>>>>>>
>>>>>> 1507124995})
>>>>>>
>>>>>> Then, I want to add those variables to my SQL database, but it does
>>>>>> not
>>>>>> work.
>>>>>>
>>>>>> var('data_received')=Client_Params;
>>>>>> local('json') = var('data_received');
>>>>>>
>>>>>> iterate(decode_json(#json), local('i'));
>>>>>>
>>>>>> var('email') =  #i -> find('email');
>>>>>> var('event') =  #i -> find('event');
>>>>>> var('message-id') =  #i -> find('message-id');
>>>>>> var('type') =  #i  -> find('type');
>>>>>>
>>>>>> if( Valid_Email(var('email')) == True );
>>>>>>
>>>>>> Inline( -Database='mydatabase',
>>>>>> -Table='hardbounced',
>>>>>> 'email'=var('email'),
>>>>>> 'event'=var('event'),
>>>>>> 'message-id'=var('message-id'),
>>>>>> 'type'=var('type'),
>>>>>> 'date'=date_format(Server_Date, -format='%Q'),
>>>>>> -Add);
>>>>>>
>>>>>> /Inline;
>>>>>>
>>>>>> /if;
>>>>>>
>>>>>> /iterate;
>>>>>>
>>>>>> #############################################################
>>>>>>
>>>>>> This message is sent to you because you are subscribed to
>>>>>> the mailing list Lasso [hidden email]
>>>>>> Official list archives available at http://www.lassotalk.com
>>>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>>>> Send administrative queries to  <[hidden email]>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>>>> Steve Piercy              Website Builder              Soquel, CA
>>>>> <[hidden email]>               <http://www.stevepiercy.com/>
>>>>>
>>>>>
>>>>> #############################################################
>>>>>
>>>>> This message is sent to you because you are subscribed to
>>>>> the mailing list Lasso [hidden email]
>>>>> Official list archives available at http://www.lassotalk.com
>>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>>> Send administrative queries to  <[hidden email]>
>>>>
>>>>
>>>>
>>>> #############################################################
>>>>
>>>> This message is sent to you because you are subscribed to
>>>> the mailing list Lasso [hidden email]
>>>> Official list archives available at http://www.lassotalk.com
>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>> Send administrative queries to  <[hidden email]>
>>>
>>>
>>>
>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>> Steve Piercy              Website Builder              Soquel, CA
>>> <[hidden email]>               <http://www.stevepiercy.com/>
>>>
>>>
>>> #############################################################
>>>
>>> This message is sent to you because you are subscribed to
>>> the mailing list Lasso [hidden email]
>>> Official list archives available at http://www.lassotalk.com
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy              Website Builder              Soquel, CA
> <[hidden email]>               <http://www.stevepiercy.com/>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Webhook data extract (JSON?)

Laurent Gigon
In reply to this post by stevepiercy
Yees! it works!! I've forget to remove a previous line of code... My
mistake, thank you Steve!

2017-10-05 12:26 GMT-04:00 Steve Piercy - Website Builder <[hidden email]>:

> Effectively you are doing this:
>
>     local('json') =
> array({"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-05
>
> 16:25:26","ts":1507213526,"message-id":"<[hidden email]>","ts_event":1507213526});
>
>     iterate(decode_json(#json), local('i'));
>
> See what's wrong with that?
>
> To fix, do this:
>
>     if(#json -> size == 1);
>         #json = #json -> get(1);
>         #json = decode_json(#json);
>     else;
>         // handle error
>     /if;
>
>     if(valid_email(#json -> find('email')));
>         inline(
>             -database='mydatabase',
>             -table='hardbounced',
>             'email'=#json -> find('email'),
>             'event'=#json -> find('event'),
>             'message-id'=#json -> find('message-id'),
>             'type'=#json -> find('type'),
>             'date'=date_format(server_date, -format='%Q'),
>             -add);
>         /inline;
>     else;
>         // handle error
>     /if;
>
> --steve
>
>
> On 10/5/17 at 10:29 AM, [hidden email] (Laurent G) pronounced:
>
>
>> I've installed client_params tag
>>
>> The original payload is :
>>
>> array:
>> ({"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-05
>>
>> 16:25:26","ts":1507213526,"message-id":"<[hidden email]>","ts_event":
>> 1507213526})
>>
>> how to insert "log_critical statements" because nothing is logged.
>>
>>
>> 2017-10-04 18:23 GMT-04:00 Steve Piercy - Website Builder
>> <[hidden email]>:
>>>
>>> Omitted questions, yadda yadda...
>>>
>>> That payload looks incomplete or incorrect due to the trailing ")".
>>>
>>> --steve
>>>
>>>
>>> On 10/4/17 at 5:09 PM, [hidden email] (Laurent G) pronounced:
>>>
>>>
>>>> This is sendinblue service, payload :
>>>>
>>>>
>>>> {"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
>>>>
>>>>
>>
>> 15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":
>>>>
>>>> 1507124995})
>>>>
>>>> nothing logged.
>>>>
>>>>
>>>>
>>>> 2017-10-04 15:24 GMT-04:00 Steve Piercy - Website Builder
>>>> <[hidden email]>:
>>>>>
>>>>>
>>>>> What specifically doesn't work?
>>>>>
>>>>> What error messages, if any, are present?
>>>>>
>>>>> Did you install the custom tag, client_params?
>>>>> http://www.lassosoft.com/tagSwap/detail/client_params/
>>>>>
>>>>> Sendgrid sends a lot more than just what you show in your "raw data".
>>>>> Please show the complete payload.
>>>>>
>>>>> Suggest you insert log_critical statements to find out where it goes
>>>>> wrong.
>>>>>
>>>>> Suggested code improvements:
>>>>>
>>>>> * Since this is a single file, use locals instead of vars.
>>>>> * This is silly:
>>>>>
>>>>>> var('data_received')=Client_Params;
>>>>>> local('json') = var('data_received');
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Do this in one step:
>>>>>
>>>>> local('json') = Client_Params;
>>>>>
>>>>> --steve
>>>>>
>>>>>
>>>>> On 10/4/17 at 10:11 AM, [hidden email] (Laurent G) pronounced:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> In order to remove hardbounced, I've created a webhook, which send
>>>>>> data to specific URL on my server. Raw data received on my server :
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> {"event":"hard_bounce","email":"[hidden email]","id":43564,"date":"2017-10-04
>>>>>>
>>>>>>
>>>>
>>>>
>>
>> 15:49:55","ts":1507124995,"message-id":"<[hidden email]>","ts_event":
>>>>>>
>>>>>>
>>>>>> 1507124995})
>>>>>>
>>>>>> Then, I want to add those variables to my SQL database, but it does
>>>>>> not
>>>>>> work.
>>>>>>
>>>>>> var('data_received')=Client_Params;
>>>>>> local('json') = var('data_received');
>>>>>>
>>>>>> iterate(decode_json(#json), local('i'));
>>>>>>
>>>>>> var('email') =  #i -> find('email');
>>>>>> var('event') =  #i -> find('event');
>>>>>> var('message-id') =  #i -> find('message-id');
>>>>>> var('type') =  #i  -> find('type');
>>>>>>
>>>>>> if( Valid_Email(var('email')) == True );
>>>>>>
>>>>>> Inline( -Database='mydatabase',
>>>>>> -Table='hardbounced',
>>>>>> 'email'=var('email'),
>>>>>> 'event'=var('event'),
>>>>>> 'message-id'=var('message-id'),
>>>>>> 'type'=var('type'),
>>>>>> 'date'=date_format(Server_Date, -format='%Q'),
>>>>>> -Add);
>>>>>>
>>>>>> /Inline;
>>>>>>
>>>>>> /if;
>>>>>>
>>>>>> /iterate;
>>>>>>
>>>>>> #############################################################
>>>>>>
>>>>>> This message is sent to you because you are subscribed to
>>>>>> the mailing list Lasso [hidden email]
>>>>>> Official list archives available at http://www.lassotalk.com
>>>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>>>> Send administrative queries to  <[hidden email]>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>>>> Steve Piercy              Website Builder              Soquel, CA
>>>>> <[hidden email]>               <http://www.stevepiercy.com/>
>>>>>
>>>>>
>>>>> #############################################################
>>>>>
>>>>> This message is sent to you because you are subscribed to
>>>>> the mailing list Lasso [hidden email]
>>>>> Official list archives available at http://www.lassotalk.com
>>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>>> Send administrative queries to  <[hidden email]>
>>>>
>>>>
>>>>
>>>> #############################################################
>>>>
>>>> This message is sent to you because you are subscribed to
>>>> the mailing list Lasso [hidden email]
>>>> Official list archives available at http://www.lassotalk.com
>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>> Send administrative queries to  <[hidden email]>
>>>
>>>
>>>
>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>> Steve Piercy              Website Builder              Soquel, CA
>>> <[hidden email]>               <http://www.stevepiercy.com/>
>>>
>>>
>>> #############################################################
>>>
>>> This message is sent to you because you are subscribed to
>>> the mailing list Lasso [hidden email]
>>> Official list archives available at http://www.lassotalk.com
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy              Website Builder              Soquel, CA
> <[hidden email]>               <http://www.stevepiercy.com/>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>