Webhook Creation: GET to callback URL does not return 200

Skip to first unread message

finn.l...@gmail.com

unread,
Aug 25, 2021, 6:00:03 AM8/25/21
to Strava API
Kia ora all,

I'm already using the API to poll for activities but would like to migrate to using Webhooks. I'm using Laravel and have a route "/api/webhook/strava" setup. When hit it runs this code:

=======================
/**
 * Handle a webhook creation
 * request.
 **/
if ($request->input("hub_mode") == "subscribe") {
    return response()->json(['hub.challenge' => $request->input("hub_challenge")]);
}

/**
 * Handle a regular request.
 **/
else {
    $model->create(["content" => $request->getContent()]);
    return response(null, 200);
}
=======================

I have checked that my API responds correctly by issuing a GET request using Postman to this URL: https://fitlytics.lesueur.nz/api/webhook/strava?hub.verify_token=STRAVA&hub.challenge=15f7d1a91c1f40f8a748fd134752feb3&hub.mode=subscribe.
All goes well and my API responds: {"hub.challenge":"15f7d1a91c1f40f8a748fd134752feb3"}

I should note that I have some logging set up so I can see what hits that URL. My test responses hit that URL as expected.

The problem comes when I issue the POST request to Strava to set up the subscription. I do a POST request to this URL with Postman, where the params are set as follows:
https://www.strava.com/api/v3/push_subscriptions?client_id=my-id&client_secret=my-secret-here&callback_url=https://fitlytics.lesueur.nz/api/webhook/strava&verify_token=STRAVA

Strava responds:
{
    "message": "Bad Request",
    "errors": [
        {
            "resource": "PushSubscription",
            "field": "callback url",
            "code": "GET to callback URL does not return 200"
        }
    ]
}

But I note that no request gets logged by my server. It's very strange! Any ideas?

Thanks for your help!
Finn

finn.l...@gmail.com

unread,
Aug 25, 2021, 5:11:07 PM8/25/21
to Strava API
I have been inspecting my logs more closely, and when I issue the POST request to create the webhook to Strava I receive a "PRI" request to my server. The log line looks like this:

108.162.250.152 fitlytics.lesueur.nz - [26/Aug/2021:08:58:54 +1200] "PRI * HTTP/2.0" 100 471 "-" "-"

Not sure what that means.
Reply all
Reply to author
Forward
0 new messages