The API Endpoints Edit String and String Batch Operation return a notUnique
code for identifier if 2 strings have the same identifier with an extra space for one of them.
When an identifier has an extra space at the end of the identifier, updating it either from the Edit Menu will do nothing. However when the string is edited using the Edit String or Batch Operation with the API, the operation will not be performed with the following error:
{
"errors": [{
"error": {
"key": "identifier",
"errors": [{
"code": "notUnique",
"message": "Invalid identifier given. Identifier must be unique"
}]
}
}]
}
Step to reproduce:
- Get a brand new account (easier to view the issue without extra string not needed).
- Create a new empty project.
- Upload the following JSON File
{
"Test String": "Test String",
"Test String ": "Test String "
}
- Optionally: You can confirm that both strings got stored correctly with correct identifier with the List String or Get String Operations:
{
"data": [
{
"data": {
"id": 2,
"identifier": "Test String",
"text": "Test String"
}
},
{
"data": {
"id": 4,
"identifier": "Test String ",
"text": "Test String "
}
}
]
}
- Send an Edit String Operation or a Batch String Operation to the project. Edit can be to replace context or text, for both of strings:
Eg: Payload send of Edit String athttps://crowdin.com/api/v2/projects/{projectId}/strings/2
:
[{"op": "replace", "path":"/context", "value": "Test String Context Updated"}]
Actual Result:
{
"errors": [{
"error": {
"key": "identifier",
"errors": [{
"code": "notUnique",
"message": "Invalid identifier given. Identifier must be unique"
}]
}
}]
}
Expected: Success of the operation as both strings have different identifiers (due to the space at the end for one of them).