Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook handle return null #80

Open
lecamen opened this issue Aug 12, 2020 · 9 comments
Open

Webhook handle return null #80

lecamen opened this issue Aug 12, 2020 · 9 comments

Comments

@lecamen
Copy link

lecamen commented Aug 12, 2020

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

@GoodsMart
Copy link

GoodsMart commented Aug 12, 2020

What the API method Get or Post

@lecamen
Copy link
Author

lecamen commented Aug 12, 2020

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

@bassem-shoukry
Copy link

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

@lecamen
Copy link
Author

lecamen commented Aug 14, 2020

Thanks, I will try it

@lecamen
Copy link
Author

lecamen commented Aug 14, 2020

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

@bassem-shoukry
Copy link

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

@lecamen
Copy link
Author

lecamen commented Aug 17, 2020

Thanks for helping guys,

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

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

@bassem-shoukry
Copy link

you need to import Illuminate\Http\Request

@lecamen
Copy link
Author

lecamen commented Aug 20, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants