0

I've had 3 developers look at this now and we cannot figure out why this test webhook on Shippo is returning a 406 error. The site is live and working fine other, so I don't understand why the webhook would have an issue communicating with the host?

Route::post('/shippo_webhooks', [JobStatusController::class, 'shippo_webhooks']);

public function shippo_webhooks(Request $request){
      $headers = $request->headers->all();
    $content = $request->getContent();
    if (!empty($content))
    {
        $post = json_decode($content, true);
    }
    if (isset($headers['x-shippo-event'][0]) && $headers['x-shippo-event'][0] == 'track_updated' &&
        (isset($headers['content-type'][0]) && $headers['content-type'][0] == 'application/json')){

        if (count($post) > 0) {
           file_put_contents(__DIR__ . '/shippo.txt', print_r($headers, true) . "\n\n\n" . print_r($post, true));
    }

    
            }
    
    http_response_code(200);
    
}
Colin
  • 85
  • 3
  • 10
  • Have you carved out a CSRF exception for the route? Although I would expect a 403 response, rather than a 406 response... – Giles Bennett Dec 20 '21 at 16:51
  • @Giles yes, I have. – Colin Dec 20 '21 at 17:00
  • OK - I'd be a bit concerned that there's some if clauses going on without any fall back (if(!empty($content)), for example - have you looked at the details of the response in something like Postman? Is the URL publicly accessible so I could try sending it a call? – Giles Bennett Dec 20 '21 at 17:06
  • @Giles - I had another developer look at it with Postman. He went back and forth with Shippo for 2 weeks with no resolution (they're support isn't that great). Here is the URL https://gray-tide.com/shippo_webhooks – Colin Dec 20 '21 at 17:23
  • What data do you get in that log file you are writing? What happens when you send a request to this endpoint yourself? – CBroe Dec 21 '21 at 09:09
  • I get a 404 on the endpoint (may be that there are IP restrictions). – Giles Bennett Dec 21 '21 at 09:41

0 Answers0