troubleshooting Question

Trying to retrieve values from webhook using Nylas API and Laravel

Avatar of tjyoung
tjyoung asked on
6 Comments1 Solution71 ViewsLast Modified:
Hi, I'm using Nylas for mail syncing and have a webhook setup in Nylas and receiving it in my Laravel application.

From Nylas docs:
"The body of the POST request is encoded as a UTF-8 JSON object with the following attributes:
Attribute        Type          Description
deltas            array          An array consisting of a single delta object."

So it seems to be a json object that contains an array??

The incoming webhook looks like this:
"deltas": [{
"date": 1577127539,
 "object": "message", 
"type": "message.created", 
"object_data": {
"namespace_id": "93d6z2qmxm050zh2znnpxxxxx", 
"account_id": "93d6z2qmxm050zh2znnpxxxxx",
 "object": "message", 
"attributes": {
"thread_id": "6ejmdhd2p0iyhscfac21yyyyy", 
"received_date": 1577127517
"id": "ioe47mlrjm592gbrc01bbbbb", 
"metadata": null

Open in new window

So my question is: how do I receive that in Laravel and get at the values?

Tried below but fails unsurprisingly (I think its because I'm receiving an object that contains an array?)

$results                   = $request->all();
$json                         = json_decode($results);
$Type                        = $json['deltas'][0]['type'];
$Thread                  = $json['deltas'][0]['object_data']['thread_id'];
$AccountId                  = $json['deltas'][0]['object_data']['account_id'];
$MessageDate            = $json['deltas'][0]['date'];
$MessageId                  = $json['deltas'][0]['object_data']['id'];

Thanks for any help in advance.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros