'Measurement Protocol v2 for GA4 in GTM server side have ex error

I send a measurement protocol v2 request from my back-end domain (via firebase_app) to my GTM server side, but my Measurement tag(MP4) throws an exception (Firing Status: Exception thrown) with console log (TypeError: Can't read property substring of undefined.)

gtm_debug_console

gtm_debug_request

gtm_debug_request-details

gtm_debug_tags

curl -i -v -# -d '{"app_instance_id":"XXXXXXXXXXXXXXXXXXX","user_id":"9999999999","timestamp_micros":"1652977756081000","non_personalized_ads":false,"events":[{"name":"purchase","params":{"items":[{"item_name":"TEST_CUSTOM","quantity":1,"item_category":"Custom contract","item_variant":"100m","price":150,"currency":"USD"}],"coupon":"TEST_COUPON","currency":"USD","transaction_id":"T_111120","value":150}}]}' -H 'x-gtm-server-preview: XXXXXXXXXXXXXX' -H "Content-Type: application/json" -X POST "https://XXXXX.XXXXXXX.XX/mp/collect?api_secret=XXXXXXXXXXX&firebase_app_id=1:XXXXXXXXX:android:XXXXXXXXXXX"

But the same request is successful on www.google-analytics.com and I see this event in realtime report GA4.

In ga-dev-tools.web.app/ga4/event-builder/ all fine and valid.

GA4 event validator

What am I doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source