Subject: Clarification on Log Ingest via AppFunction with Api-Token
Hi imsingh,
First off, I just wanted to compliment you on the excellent and informative videos you created on Dynatrace University — they’ve been a huge help.
While building my first AppFunction, I ran into a limitation that I hope you might be able to clarify.
I was trying to call the v2/logs/ingest API from within an AppFunction using an Api-Token. This call works perfectly when made externally (e.g. from Python or Postman), but inside the AppFunction I received the following error:
“Unsupported authorization scheme ‘Api-Token’. Dynatrace platform APIs require the authorization scheme ‘Bearer’.”
Here’s the full error payload, in case it helps:
{ “error”: { “code”: 401, “message”: “Unsupported authorization scheme ‘Api-Token’. Dynatrace platform APIs require the authorization scheme ‘Bearer’.”, “details”: { “traceId”: “c25be4adefbbb1296f15adf13a275196” } } }
I now understand that AppFunctions operate within the Dynatrace Platform context, which requires Bearer authentication — but unfortunately, the v2/logs/ingest endpoint doesn’t currently support Bearer tokens or OAuth clients. This caught me off guard and was admittedly a bit frustrating, as I expected parity between external and platform-internal API usage.
I also explored the Developer Portal and came across @dynatrace-sdk/client-classic-environment-v2, but I wasn’t sure if this is the right approach for ingesting logs from within an AppFunction. I wasn’t able to install the package or find a working example using the logsClient.
Given that my use case is quite simple — just forwarding a small set of JSON events into Dynatrace from within an AppFunction — could you please recommend the best-supported method to do this from inside the platform? A sample the proper SDK or HTTP call would be extremely helpful.
Really appreciate your time and guidance.
Best regards,
MarwanC