POST /Server/WriteTitleEvent HTTP/1.1 Host: d5611.playfabapi.com X-SecretKey: Content-Type: application/json Content-Length: 139 { "EventName" : "transaction_finished", "Body" : { "Hook" : "https://webhook.site/0f49d79f-a73e-4f41-8718-53b7a5091c79" } }
I'm sending this from some online rest verifier.
The event is registered in PlayStream/Event History. This is the JSON:
{ "EventName": "transaction_finished", "EventNamespace": "title.D5611", "EntityType": "title", "Source": "D5611", "EventId": "20a0bf2ebc3544bda24fe0d34e84a5d6", "EntityId": "D5611", "SourceType": "GameServer", "Timestamp": "2020-08-27T18:36:00.9677012Z", "PlayFabEnvironment": { "Vertical": "master", "Cloud": "main", "Application": "mainserver", "Commit": "2c5a25d" }, "Hook": "https://webhook.site/0f49d79f-a73e-4f41-8718-53b7a5091c79" }
The image attached is what my Rule looks like.
Finally, here's the cloudscript method.
var failedWebhookQueues = []; handlers.syncTransactions = function (args, context) { let hook = context.playStreamEvent.Hook; if(!hook) { log.error("No response url."); } else { let content = {TxnId : "TX10222", Status: "Success"}; server.WriteTitleEvent({EventName : "cs_ran_syncTransactions"}); let hookResult = http.request(hook, "post", JSON.stringify(content) , "application/json", {owo, whats : this}); let parsed = JSON.parse(hookResult); if(parsed.code !== "200") { failedWebhookQueues.Add(content); } } return {failedWebhookQueues, hook}; }
Any help would be appreciated.