How can I update a record with modular field

Hello I have this response from dato cms API

{
    "data": [
        {
            "id": "D1Bs9ivTSEiQ2d0GMx1ZKw",
            "type": "item",
            "attributes": {
                "setup": [
                    {
                        "type": "item",
                        "attributes": {
                            "logo_header": {
                                "alt": null,
                                "title": null,
                                "custom_data": {},
                                "focal_point": null,
                                "upload_id": "QiIBMn5iQQ6vDf1PvG0Inw"
                            },
                            "logo_header_dark": {
                                "alt": null,
                                "title": null,
                                "custom_data": {},
                                "focal_point": null,
                                "upload_id": "ASbiMPGDQmq4Ekkg6Eyz8g"
                            },
                            "logo_app_saleor": {
                                "alt": null,
                                "title": null,
                                "custom_data": {},
                                "focal_point": null,
                                "upload_id": "QiIBMn5iQQ6vDf1PvG0Inw"
                            },
                            "pakal_head_script": [],
                            "pakal_body_script": []
                        },
                        "relationships": {
                            "item_type": {
                                "data": {
                                    "id": "NfEX0bDbTrexsw8FGLQACg",
                                    "type": "item_type"
                                }
                            }
                        },
                        "id": "EM1IWdIBS4OaZg7u11KDlw"
                    }
                ],
                "pakal_saleor_app_token": "3ujiUS1QKgsFRSFnIv1ZPW7XbiB608",
                "pakal_importer_shiphero": [
                    {
                        "type": "item",
                        "attributes": {
                            "url": "Test URL",
                            "api_key": "Test APIKEY",
                            "default_channel": "Q2hhbm5lbDox",
                            "default_product_type": "Test Default Product",
                            "default_warehouse": "Test Warehouse",
                            "product_barcode": "",
                            "product_tags": "",
                            "product_type": "",
                            "product_vendor": ""
                        },
                        "relationships": {
                            "item_type": {
                                "data": {
                                    "id": "F8QMLJhUQyW_mj_SU1wHmA",
                                    "type": "item_type"
                                }
                            }
                        },
                        "id": "Tam_k7dSQrGWkaURu0OnIQ"
                    }
                ],
                "updated_at": "2024-01-02T16:11:14.497-08:00",
                "created_at": "2024-01-01T09:47:44.812-08:00"
            },
            "relationships": {
                "item_type": {
                    "data": {
                        "id": "bpIeQUP-SxOH2i5OG3cr2Q",
                        "type": "item_type"
                    }
                },
                "creator": {
                    "data": {
                        "id": "39091",
                        "type": "user"
                    }
                }
            },
            "meta": {
                "created_at": "2024-01-01T09:47:44.812-08:00",
                "updated_at": "2024-01-02T16:11:14.497-08:00",
                "published_at": "2024-01-02T16:11:14.539-08:00",
                "publication_scheduled_at": null,
                "unpublishing_scheduled_at": null,
                "first_published_at": "2024-01-01T09:47:44.850-08:00",
                "is_valid": true,
                "is_current_version_valid": true,
                "is_published_version_valid": true,
                "status": "published",
                "current_version": "Kvx5wbgrQ3Oqv3aVe0E90w",
                "stage": null
            }
        }
    ],
    "meta": {
        "total_count": 1
    }
}

I would like to update pakal_importer_shiphero attributes. what is the correct way to send the request? I’m using the rest API to do it because I’m working with python/Django

I tried to do it in this way

{
"data":[
  // we don't need to change anything to these two blocks, just pass their IDs:
  "EM1IWdIBS4OaZg7u11KDlw",  
  // we want to change some field values for this block!
  {
    "id": "Tam_k7dSQrGWkaURu0OnIQ",
    "type": "item",
    "attributes": {
        "url": "Test URL",
        "api_key": "Test APIKEY",
        "default_channel": "Q2hhbm5lbDox",
        "default_product_type": "Test Default Product",
        "default_warehouse": "Test Warehouse",
        "product_barcode": "",
        "product_tags": "",
        "product_type": "",
        "product_vendor": ""
      
    },
    "relationships": {
      "item_type": {
        "data": {
            "id": "F8QMLJhUQyW_mj_SU1wHmA",
            "type": "item_type"
        }
      }
    }
  }
]
}

but I received this error:

{
    "data": [
        {
            "id": "c99fc9",
            "type": "api_error",
            "attributes": {
                "code": "INVALID_FORMAT",
                "details": {
                    "messages": [
                        "#/data: failed schema #/definitions/item/links/5/schema/properties/data: For 'properties/data', [\"EM1IWdIBS4OaZg7u11KDlw\", {\"id\"=>\"Tam_k7dSQrGWkaURu0OnIQ\", \"type\"=>\"item\", \"attributes\"=>{\"url\"=>\"Test URL\", \"api_key\"=>\"Test APIKEY\", \"default_channel\"=>\"Q2hhbm5lbDox\", \"default_product_type\"=>\"Test Default Product\", \"default_warehouse\"=>\"Test Warehouse\", \"product_barcode\"=>\"\", \"product_tags\"=>\"\", \"product_type\"=>\"\", \"product_vendor\"=>\"\"}, \"relationships\"=>{\"item_type\"=>{\"data\"=>{\"id\"=>\"F8QMLJhUQyW_mj_SU1wHmA\", \"type\"=>\"item_type\"}}}}] is not an object."
                    ]
                }
            }
        }
    ]
}

thanks

We resolved this in Slack, but for anyone else wondering, the shape for an HTTP record update call to a modular content field should look like like this:

PUT https://site-api.datocms.com/items/D1Bs9ivTSEiQ2d0GMx1ZKw (the record ID)

{
  "data": {
    "id": "D1Bs9ivTSEiQ2d0GMx1ZKw", // Same as the record ID in the uRL
    "type": "item",
    "attributes": {
      "pakal_importer_shiphero": [ // Name of your modular content field
          "another_block_id", // For any block you want to keep as-is without updates, just provide their IDs as a string
        {
          "id": "FDVMlS8JScGiZQIUkqnWCw", // Block ID that you want to update
          "type": "item", 
          "attributes": {
                "url": "Updated Test URL",
                "api_key": "Updated Test APIKEY",
                "default_channel": "Updated Q2hhbm5lbDox",
                "default_product_type": "Updated Test Default Product",
                "default_warehouse": "Updated Test Warehouse",
                "product_barcode": "Updated Barcode",
                "product_tags": "Updated Tags",
                "product_type": "Updated Type",
                "product_vendor": "Updated Vendor"

          },
          "relationships": {
            "item_type": {
              "data": {
                "type": "item_type",
                "id": "Fj-f9fHtTj-2co_u5aFXsA" // Block model (not record) ID
              }
            }
          }
        }
      ]
    }
  }
}

We’ll update the documentation on HTTP record updates soon, sorry about that!