Closed kevinLourencoDev closed 6 months ago
Hi @kevinLourencoDev, could you please try the same request in Postman to define if whether it's the API issue or the API Client issue? Thank you!
Sure, i tried a simple curl one:
curl -X PATCH "https://client.api.crowdin.com/api/v2/projects/11/strings" \
-H "Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-H "Content-Type: application/json" \
-d '[{
"op": "add",
"path": "/-",
"value": {
"text": "new added string",
"identifier": "a.b.c",
"context": "context for new string",
"fileId": 1,
"isHidden": false
}
}]'
And we have as we would like a result:
{"data":[{"data":{"id":627408,"projectId":1,"branchId":null,"identifier":"a.b.c","text":"new added string","type":"text","context":"a.b.c\ncontext for new string","maxLength":0,"isHidden":false,"isDuplicate":false,"masterStringId":null,"hasPlurals":false,"isIcu":false,"labelIds":[],"createdAt":"2023-12-01T14:12:42+00:00","updatedAt":null,"fileId":1701,"directoryId":1537,"revision":16}}]}
I confirm the issue might come from API Client !
@kevinLourencoDev thanks a lot for the details and the confirmation!
@andrii-bodnar do you have any visibility on this error base on the priority of it? Would you need more help to fix it?
@kevinLourencoDev since this is an API Client issue, we'd be happy to accept contributions!
Feel free to read the contributing guidelines for more details.
Hi @kevinLourencoDev,
Could you try using this
var patches = sourceStrings.Select(sourceString => new CrowdinSourceStrings.StringBatchOpPatch()
{
Operation = Crowdin.Api.PatchOperation.Add,
Value = new CrowdinSourceStrings.AddStringRequest()
{
Identifier = "test",
Text = "test",
Context = "test",
FileId = 1,
IsHidden = false
}
}
).ToList();
var response = await _crowdinClientWrapper.BulkEditSourceStrings(projectId, patches);
As new source strings are added using AddStringRequest Object rather than SourceString.
Hi @andrii-bodnar, I think the user must not be able to instantiate a source string object. It should always come from API only.
Hi,
In both version 2.18 and 2.19, StringBatchOperations seems to not send the correct ResponseList and send return result: null
Here is the simple client call:
And there is how we created patches:
Patches seem to be well formatted if we consider it's required to be only an array of {Crowdin.Api.SourceStrings.StringBatchOpPatch} following https://developer.crowdin.com/api/v2/#operation/api.projects.strings.post
High chance the feature is simply not working, since my implementation is simple. Let me know if you need more informations !