php-trello-api icon indicating copy to clipboard operation
php-trello-api copied to clipboard

Webhook handle return null

Open lecamen opened this issue 4 years ago • 9 comments

In webhook handle I can't get the "action" data.

I've checked this$request->getContent() it has data

But, in this in code $request->get('action') return null

I try it this way I got 500 Internal Server Error

if (!$this->isTrelloWebhook($request)) {
  return;
}

$action = json_decode($request->getContent(), true)['action'];

Anyone have and idea how to catch the request?

Thank you

lecamen avatar Aug 12 '20 12:08 lecamen

What the API method Get or Post

GoodsMart avatar Aug 12 '20 12:08 GoodsMart

In trello it use POST in receiving. btw this is in laravel

lecamen avatar Aug 12 '20 12:08 lecamen

try to move your route to api.php instead of web.php and use (any) instead of (post) and try again

bassem-shoukry avatar Aug 13 '20 13:08 bassem-shoukry

Thanks, I will try it

lecamen avatar Aug 14 '20 05:08 lecamen

I'm still received null value in $request->get('action') both web and api.

Here in screenshot the data is available

Screen Shot 2020-08-14 at 4 50 20 PM

Maybe I did wrong implementation. What is the best way to implement in laravel? I did it in AppServiceProvider.php

lecamen avatar Aug 14 '20 08:08 lecamen

try
$input = $request->all(); \Log::info(json_encode($input['action']['data']));

bassem-shoukry avatar Aug 16 '20 10:08 bassem-shoukry

Thanks for helping guys,

For this $input = $request->all(); it return error from HttpFoundation

Error: Call to undefined method Symfony\Component\HttpFoundation\Request::all()

lecamen avatar Aug 17 '20 09:08 lecamen

you need to import Illuminate\Http\Request

bassem-shoukry avatar Aug 17 '20 15:08 bassem-shoukry

Hi still isn't working inside

public function handleWebhook(Request $request = null)
    {
        if (!$request) {
            $request = Request::createFromGlobals();
        }

        if (!$this->isTrelloWebhook($request) || !$action = $request->get('action')) {
            return;
        }
 ****
 ****
}

Illuminate\Http\Request will on passing the $request

e.g $this->service->handleWebhook($request);

But, new issues found :)

Screen Shot 2020-08-20 at 10 53 21 PM

-- I think this api need to be update.

Thanks.

lecamen avatar Aug 20 '20 15:08 lecamen