0

I'm trying to POST a multilingual content like this :

POST : $URL/node?_format=json

    {
    "type": [
        {
            "target_id": "movie",
            "target_type": "node_type"
        }
    ],
    "title": [
        {
            "value": "film_postman_en",
             "lang": "en"
        },
         {
            "value": "film_postman_fr",
             "lang": "fr"
        }
    ]
}

And I receive the following response:

"message": "Unprocessable Entity: validation failed.\ntitle: Title: this field cannot hold more than 1 values.\n"

I also tried the PATCH method :

1.POST : http://$URL/node?_format=json Content-Type:application/json Accept:application/json BODY Request :

{
    "type": [
        {
            "target_id": "movie",
            "target_type": "node_type"
        }
    ],
    "title": [
        {
            "value": "film_postman"
        }
    ],
    "langcode": [
        {
            "value": "en"
        }
    ]
}

BODY Response :

{
    "nid": [
        {
            "value": 112
        }
    ],
    "uuid": [
        {
            "value": "97825457-0b64-4255-974c-7724c48bac9d"
        }
    ],
    "vid": [
        {
            "value": 119
        }
    ],
    "langcode": [
        {
            "value": "en"
        }
    ],
    "type": [
        {
            "target_id": "movie",
            "target_type": "node_type",
            "target_uuid": "aebe1f8c-3223-4d82-baca-da07dfbd1f76"
        }
    ],
    "revision_timestamp": [
        {
            "value": "2022-07-20T15:49:13+00:00",
            "format": "Y-m-d\\TH:i:sP"
        }
    ],
    "revision_uid": [
        {
            "target_id": 1,
            "target_type": "user",
            "target_uuid": "5486091d-dade-49f3-a6e8-92afda5cfc5c",
            "url": "/en/user/1"
        }
    ],
    "revision_log": [],
    "status": [
        {
            "value": true
        }
    ],
    "uid": [
        {
            "target_id": 1,
            "target_type": "user",
            "target_uuid": "5486091d-dade-49f3-a6e8-92afda5cfc5c",
            "url": "/en/user/1"
        }
    ],
    "title": [
        {
            "value": "film_postman"
        }
    ],
    "created": [
        {
            "value": "2022-07-20T15:49:13+00:00",
            "format": "Y-m-d\\TH:i:sP"
        }
    ],
    "changed": [
        {
            "value": "2022-07-20T15:49:13+00:00",
            "format": "Y-m-d\\TH:i:sP"
        }
    ],
    "promote": [
        {
            "value": false
        }
    ],
    "sticky": [
        {
            "value": false
        }
    ],
    "default_langcode": [
        {
            "value": true
        }
    ],
    "revision_translation_affected": [
        {
            "value": true
        }
    ],
    "metatag": {
        "value": {
            "canonical_url": "http://127.0.56.3/en",
            "shortlink": "http://127.0.56.3/en",
            "title": "| Gaumont PRO"
        }
    },
    "path": [
        {
            "alias": null,
            "pid": null,
            "langcode": "en"
        }
    ],
    "content_translation_source": [
        {
            "value": "und"
        }
    ],
    "content_translation_outdated": [
        {
            "value": false
        }
    ],
    "body": [],
    "field_appointments": [],
    "field_availability": [],
    "field_awards": [],
    "field_cast": [],
    "field_color": [
        {
            "value": false
        }
    ],
    "field_dialogist": [],
    "field_director": [],
    "field_duration": [],
    "field_genre": [],
    "field_header_image_desktop": [],
    "field_header_image_mobile": [],
    "field_image_technology": [],
    "field_is_actually": [
        {
            "value": false
        }
    ],
    "field_is_an_animation": [
        {
            "value": false
        }
    ],
    "field_is_coming_soon": [
        {
            "value": false
        }
    ],
    "field_lang": [],
    "field_nationality": [],
    "field_production_year": [],
    "field_public": [],
    "field_release_date": [],
    "field_resolution": [],
    "field_scriptwriter": [],
    "field_sound": [],
    "field_subtitle": [
        {
            "value": false
        }
    ],
    "field_twitter_hashtag": [],
    "field_weight": []
}
  1. PATCH : http://$URL/node/112?_format=json

Content-Type:application/json Accept:application/json BODY Request :

{
    "langcode": [
        {
            "value": "fr"
        }
    ],
    "title": [
        {
            "value": "film_postman_fr"
        }
    ],
    "type": [
        {
            "target_id": "movie",
            "target_type": "node_type",
            "target_uuid": "aebe1f8c-3223-4d82-baca-da07dfbd1f76"
        }
    ]
}

BODY Response :

{
    "nid": [
        {
            "value": 112
        }
    ],
    "uuid": [
        {
            "value": "97825457-0b64-4255-974c-7724c48bac9d"
        }
    ],
    "vid": [
        {
            "value": 119
        }
    ],
    "langcode": [
        {
            "value": "fr"
        }
    ],
    "type": [
        {
            "target_id": "movie",
            "target_type": "node_type",
            "target_uuid": "aebe1f8c-3223-4d82-baca-da07dfbd1f76"
        }
    ],
    "revision_timestamp": [
        {
            "value": "2022-07-20T15:49:13+00:00",
            "format": "Y-m-d\\TH:i:sP"
        }
    ],
    "revision_uid": [
        {
            "target_id": 1,
            "target_type": "user",
            "target_uuid": "5486091d-dade-49f3-a6e8-92afda5cfc5c",
            "url": "/en/user/1"
        }
    ],
    "revision_log": [],
    "status": [
        {
            "value": true
        }
    ],
    "uid": [
        {
            "target_id": 1,
            "target_type": "user",
            "target_uuid": "5486091d-dade-49f3-a6e8-92afda5cfc5c",
            "url": "/en/user/1"
        }
    ],
    "title": [
        {
            "value": "film_postman_fr"
        }
    ],
    "created": [
        {
            "value": "2022-07-20T15:49:13+00:00",
            "format": "Y-m-d\\TH:i:sP"
        }
    ],
    "changed": [
        {
            "value": "2022-07-20T15:49:13+00:00",
            "format": "Y-m-d\\TH:i:sP"
        }
    ],
    "promote": [
        {
            "value": false
        }
    ],
    "sticky": [
        {
            "value": false
        }
    ],
    "default_langcode": [
        {
            "value": true
        }
    ],
    "revision_translation_affected": [
        {
            "value": true
        }
    ],
    "metatag": {
        "value": {
            "canonical_url": "http://127.0.56.3/en/node/112",
            "title": "film_postman_fr | Gaumont PRO"
        }
    },
    "path": [
        {
            "alias": "/film/filmpostmanfr",
            "pid": 905,
            "langcode": "fr"
        }
    ],
    "content_translation_source": [
        {
            "value": "und"
        }
    ],
    "content_translation_outdated": [
        {
            "value": false
        }
    ],
    "body": [],
    "field_appointments": [],
    "field_availability": [],
    "field_awards": [],
    "field_cast": [],
    "field_color": [
        {
            "value": false
        }
    ],
    "field_dialogist": [],
    "field_director": [],
    "field_duration": [],
    "field_genre": [],
    "field_header_image_desktop": [],
    "field_header_image_mobile": [],
    "field_image_technology": [],
    "field_is_actually": [
        {
            "value": false
        }
    ],
    "field_is_an_animation": [
        {
            "value": false
        }
    ],
    "field_is_coming_soon": [
        {
            "value": false
        }
    ],
    "field_lang": [],
    "field_nationality": [],
    "field_production_year": [],
    "field_public": [],
    "field_release_date": [],
    "field_resolution": [],
    "field_scriptwriter": [],
    "field_sound": [],
    "field_subtitle": [
        {
            "value": false
        }
    ],
    "field_twitter_hashtag": [],
    "field_weight": []
}
4
  • I believe you have to submit each language on its own, so two calls to the API, not one.
    – Jaypan
    Jul 20, 2022 at 15:12
  • A post can(t be done only once. I tried a POST and a PATCH but the EN version disappear when I patch with the FR version :( Jul 20, 2022 at 15:20
  • Well, that indicates you likely made a mistake in saving the second call. You'd have to show us what that was for us to be able to provide assistance though.
    – Jaypan
    Jul 20, 2022 at 15:41
  • @Jaypan I added more details in the main post Jul 20, 2022 at 16:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.