Skip to content

Updating a localized field via multiple REST API saves one value #13000

Open
@kazantseva-anna-front

Description

@kazantseva-anna-front

Link to reproduction

No response

Describe the Bug

There is a problem when I try to save two translations, only one is saved. Are there any options to avoid this?

async function updateProductLocale(id, locale, data) {
  const url = '${process.env.PAYLOAD_API}/products/${id}?locale=${locale}'

  const res = await axios.patch(
    url,
    data,
    {
      headers: {
        Authorization: `API-Key ${process.env.PAYLOAD_SECRET}`,
        'Content-Type': 'application/json',
      },
    }
  )
  return res.data
}

await updateProductLocale(existingProduct.id, 'uk', {
  title: storyUk.name || '',
  body: bodyUk.length ? bodyUk : [],
})

await updateProductLocale(existingProduct.id, 'ru', {
  title: storyRu?.name || '',
  body: bodyRu.length ? bodyRu : [],
})
`

To Reproduce

I need to automatically transfer data from an existing CMS to Payload using a script. At this stage, I cannot simultaneously update translations for a page in two languages ​​at once.

Payload Version

3.43.0

Adapters and Plugins

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs-triagePossible bug which hasn't been reproduced yetv2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions