I'm working on a Lua based client and am using Azure Functions as part of my analytics pipeline. The analytical events are batched on the Lua client and send to the Azure Function. The Azure Function then formats the data for PlayFab, and attempts to call /Event/WriteEvents or /Event/WriteTelemetryEvents based on a value I pass up.
The problem that I'm running into is with the EntityToken header that's required by these endpoints. Our analytics pipeline is disassociated with players after an event is queued. This means that after the player's entity information is stored in the event payload, all PlayFab calls, including the one to the Azure Function are made on behalf of the title. This approach works up until it's time to actually make the HTTP call to /Event/WriteEvents and /Event/WriteTelemetryEvents.
From my experimentation it seems that an EntityToken registered on behalf of a player is accepted while an EntityToken registered on behalf of the TitleId is not. Below is the code that is responsible for making the request. Right now, I'm currently passing EntityToken in the request body, which may or may not be required. I'm fairly new to this API so any help is appreciated. You'll notice that I index `entityToken` with `data` inside the MakeRequest body. This is because the EntityToken that's passed is the raw JSON that's returned when /GetEntityToken is called.
// Construct request let request = { EntityToken: entityToken.data, Events: events } // Call endpoint based on eventType let endpoint = "Event/WriteTelemetryEvents"; if (eventType == Enums.AnalyticEventType.PlayStream) { endpoint = "/Event/WriteEvents"; } // Make request to PlayFab Api GamePlayFab.MakeRequest( GamePlayFab.GetServerUrl() + endpoint, request, "X-EntityToken", entityToken.data, function (error, result) { if (typeof(result) === undefined) { return reject(error); } else { return resolve(result); } }, );