Trying to create webhook subscription in MS Graph for mail messages.
Posting the request in FM, getting a 405 Method not allowed error.
Posting same request in Postman, getting “Subscription validation request failed. Notification endpoint must respond with 200 OK to validation request.”
API Key configured.
Webhook registered.
FM Insert from URL as follows:
URL: https://graph.microsoft.com/v1.0/subscriptions
cURL: -X Post -H “Authorization: Bearer {{token}}” -H “Content-type: application/json” -D $header -d @$data
$data: {
“changeType” : “created”,
“clientState” : “secretClientState”,
“expirationDateTime” : “2024-06-24T13:52:43.0000000Z”,
“notificationUrl” : “https://{{domain}}.com/otto/receiver/Webhook Receiver.fmp12/libdocs?apiKey={{key}}”,
“resource” : “/users/{{id}}/messages”
}
OttoFMS Webhooks do not natively handle validation requests, but you can build it into the reciever script with Webhook Responses. You should be able to accept the incoming validation requests and set up the response to send a 200 yourself.
The Microsoft docs have a walkthrough that should let you know how the incoming request will be structured and how you will need to set up the response.
The token should be passed through as part of the script params from OttoFMS. I would try using it the way it is passed in first as I am not sure if it will be encoded still at that point. If it is still encoded you will need to decode it. FileMaker does not have a built in function to decode URL-encoded strings (as far as I know) you’ll need to use a custom function to decode it.
You’ll have to do some debugging of the token that you’re getting from the request and see what value you’re getting.
The query parameters are passed to the OttoReceiver Script as the Script Parameter. You can modify the OttoReceiver script to use Get(ScriptParameter) to get those values and either pass them into the payload or Put them in a different field which you can create for this purpose, or just pass them to your script.
Let us know if we have given you enough information to get this in place.