Rest Hook Subscription (Input could not be converted to a valid request)

I’m trying to make a request to the REST hooks endpoint but the body I’m sending must be incorrect, despite reading the documentation I fear I must be missing something here.

var hookRequest = {
    "eventKey": hook,
    "hookUrl": SELF_URI
};

var options = {
    "method": "post",
    "contentType": "application/json",
    "headers": {
        "Authorization": "Bearer " + userProperties.getProperty("accessToken"),
        "Accept": "application/json, */*"
    },
    "payload": {
        "restHookRequest": JSON.stringify(hookRequest)
    }
};

var response = UrlFetchApp.fetch(
    BASE_URI + "hooks",
    options
);

Every time I make this request, encoded as JSON or otherwise, I receive a HTTP 400 response with the “Input could not be converted to a valid request” body.

Could anybody point out where this may be going wrong? According to the docs, in Google App Scripts, the Content-Type header is not passed in the header object here but I’ve tried both (Using their “contentType” property and also “Content-Type”. I’ve also tried submitting the payload directly as a property of “options” here but I receive the 400 regardless of whether the eventKey and hookUrl are in the payload object. I’ve also checked the logs to ensure that the Authorization header is being correctly put together (accessToken is never empty) and it appears fine.

I’ve verified that the hook and SELF_URI variables are correctly being interpreted as the correct strings and I’ve gone so far as to try this HookRequest object in the “Try The API” REST docs, which worked perfectly so I’m lead to believe it may be something else, potentially outside the scope of this community?

Thanks in advance if anybody gets time to look at this.

The only thing that I see is a bit strange is the Accept header, which we only specify as “application/json”, but generally that won’t cause an issue. Other than that, I would probably try to capture the outgoing request, possibly by debugging that UrlFetchApp.fetch method and seeing what is actually being sent to the server, then replicating that in a tool like Postman to see if it is correct.