'Why is Shippo Webhook returning 406 error?
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);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|