Translation is not created/updated when using the API, despite "OK" response

A project and resource both exist, and I am trying to create translations for languages.

I am using the URL: https://www.transifex.com/api/2/project/example-project-name/resource/example-resource-name/translation/fr_FR/strings/

I am creating a PUT request, with the payload:

[ { "key": "example-key.example-key", "context": "", "source_string": "Foo", "translation": "Bar" } ]

The key matches the source string in the transifex dashboard. The API user being used for the request is the project maintainer, so should have rights to do this action.

The response is a 200 response and has the content “OK”, so no errors are being reported, yet the translations are NOT added.

Hello

Thank you for reaching out to us.

I notice you are using the key as an identifier, and you are missing the string hash. The string hash is used to identify the string. So you need to add something like this:“source_entity_hash”: “e9fbd679f07d178744bfa80344080962”. Using string hashes is further described here: Translation Strings | Transifex Documentation. Please let me know if this helps.

Kind Regards,

Hi,

I started digging around and found: Examples of API Calls | Transifex Documentation, which works for a single string. From that I did some playing around, and yes, the payload with just the translation + adding in source_string_hash works with the API for sending multiple strings for a language at once.

In case anyone else comes across this looking for a solution:

API URL: https://www.transifex.com/api/2/project/<project-slug>/resource/<resource-slug>/translation/<language_code>/strings/

PUT request, with the payload:

[ { "source_string_hash": "312cc65a42643dde5c1d529b2e9fa95d", "translation": "Bar" } ]

The source string hash is calculated as seen here: Examples of API Calls | Transifex Documentation

I think the problem is resolved now (I can see translations creating & updating, yay!), though is there any way I can help update the documentation for my use case?

Hello

I appreciate your feedback. What would you think would better explain your use case in our documentation? Did the links to the API examples and the source string hash calculation help?

I look forward to your feedback.

Kind Regards,