HTTP Status code 400 - invalid parameter - "Unexpected key \"index\"

Hey!
I get a HTTP Status code 400 for every FB Event (viewcontent, etc.).
This is the reason:
“{“error”:{“message”:“Invalid parameter”,“type”:“OAuthException”,“code”:100,“error_subcode”:2804019,“is_transient”:false,“error_user_title”:“Parameterfehler bei serverseitiger API”,“error_user_msg”:“Unexpected key "index" on param "$[‘data’][0][‘custom_data’][‘contents’][0]".”}}”

I understand, that “index” should not appear. But that´s how my data layer works I guess (see picture). How can I stop sending the index-parameter to FB?
Screenshot 2024-07-07 180109

Thank you very much!

@Malaui well, the easiest would be to override contents in your FB tag, so that that parsing from items is not attempted which brings the error according to you description.

I don’t see how that ‘index’ field would affect it though, could you please share the tag itself firing with all the params expended and with values (blackout the sensitive stuff of coruse) - might have more insights

The error has changed a little bit…
It´s about item_name now.

“{“error”:{“message”:“Invalid parameter”,“type”:“OAuthException”,“code”:100,“error_subcode”:2804019,“is_transient”:false,“error_user_title”:“Parameterfehler bei serverseitiger API”,“error_user_msg”:“Unexpected key "item_name" on param "$[‘data’][0][‘custom_data’][‘contents’][0]".”}}”

Here are 2 screenshots of the Tag.
Thanks!


Well of course…you are sending items array as contents parameter, your errors are because you are sending keys that contents parameter does not support. Remove contents altogether from Custom Data section, the tag will then auto-parse your items array and send proper parameter.

thanks. yes, thats what I also thought. But when I remove it, I get this error:

{“error”:{“message”:“Invalid parameter”,“type”:“OAuthException”,“code”:100,“error_subcode”:2804008,“is_transient”:false,“error_user_title”:“Ung\u00fcltiger Content-Parameter”,“error_user_msg”:“Der eingegebene Content-Parameter enth\u00e4lt keine Liste mit JSON-Objekten. Gib eine Liste mit JSON-Objekten ein, die die Produkt-IDs enthalten, die dem Event zugeordnet sind, sowie Informationen zu den Produkten. Beispiel: [{ ‘id’ : ‘ABC123’, ‘quantity’ : ‘2’, ‘item_price’ : 5.99}, { ‘id’ : ‘XYZ789’ , ‘quantity’ : 2, ‘item_price’ : 9.99}]”,}}

As far as I can see, the “item_id” is missing. Strangely, this is shown as “content_id” in the events “Begin_checkout” and “purchase” under event data. In the event “add_to_content” the “item_id” is still specified and not “content_id”. I don’t get an error message here either. In my opinion, the error is that “item_id” suddenly becomes “content_id”, or am I wrong here?

can you show me request body please

{“data”:[{“event_name”:“Purchase”,“action_source”:“website”,“event_time”:1720525381,“custom_data”:{“contents”:[{“title”:“Schnullerkette”,“brand”:“xxx”,“quantity”:1,“category”:“Schnullerkette”,“item_price”:16.95},{“title”:“Schnullerkette”,“brand”:“xxx”,“quantity”:1,“category”:“Schnullerkette”,“item_price”:16.95}],“content_type”:“product”,“currency”:“EUR”,“order_id”:“44045273956xxx”,“value”:“0.00”,“items”:[{“item_name”:“Schnullerkette”,“item_variant”:“Hellblau”,“discount”:0,“price”:16.95,“quantity”:1,“item_brand”:“xxx”,“item_category”:“Schnullerkette”,“product_id”:8055386538xxx,“variant_id”:48132196532xxx,“sku”:“14:200003699xxx”,“content_id”:“shopify_DE_8055386538xxx_48132196532xxx”},{“item_name”:“Schnullerkette”,“item_variant”:“Altgrün”,“discount”:0,“price”:16.95,“quantity”:1,“item_brand”:“xxx”,“item_category”:“Schnullerkette”,“product_id”:8055386538xxx,“variant_id”:48132196434xxx,“sku”:“14:200003699xxx”,“content_id”:“shopify_DE_8055386538xxx_48132196434xxx”}]},“user_data”:{“client_user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36”,“client_ip_address”:“141.31.128.xx”,“fbp”:“fb.1.1720279001xxx.40019103152742xxx”,“em”:“fbffb5dbad102b73e9eea37fc8ba2362fffcbbab6bb7a3fe658d7ecace9a8634”,“ph”:“3e48b33d7e4c01417fd80bffea4404d3d9494300d72bfc4e7fa8a474f950a2bd”,“ln”:“78a7edfb3adb263c381f942170ee5813160d4017f13c615a6c067473ecca439a”,“fn”:“1d4b41c9db9172e5f151e4a5fe3c57ca3f98b8e6ba807450b10d1897c84ce72b”,“ct”:“9dc5bad7a55031b93aeb1dd8d76673d84582fb0faeb4ecdb1b99423296447651”,“zp”:“15e579a1f1c25a96ae884a841efed38f9ee86c6547918be3547a093c97a3725d”,“country”:“76b64fa3652825ae1348dc2109d3c127b27decd34beb4cf010c302e4c13fb7aa”},“event_source_url”:“https://www.xxx.de/checkouts/cn/ef34ec0bb24a2f64bd16533eaa4e4d0f/thank_you",“event_id”:“1720278726xxx_1720525845449xxx”}],“partner_agent”:“stape-gtmss-2.1.1-ee”,“test_event_code”:"TEST68xxx”}

As written in your original error, the problem you have is in the format of the contents parameter. Here is how you send it:

And here’s where you can find how FB expects to get it: Paramètres standard - API Conversions - Documentation - Meta for Developers

A list of JSON objects that contain the product IDs associated with the event plus information about the products. Available fields: id , quantity , item_price , delivery_category.

Also, there is usually not any point in sending items to FB, it is the format for GA4. For FB, you send item data in ‘content_ids’ and/or ‘contents’ params.