crowdin / crowdin-api-client-dotnet

.NET client library for Crowdin API
https://www.nuget.org/packages/Crowdin.Api/
MIT License
50 stars 27 forks source link

UploadTranslations not working for XLIFF file #228

Closed adamcsillag closed 2 months ago

adamcsillag commented 4 months ago

Hi,

The following code fails with the error message: Crowdin.Api.CrowdinApiException: 'Invalid Request Parameters: Key [fileId]: The input is not greater than '0''

  await using FileStream fileStream = System.IO.File.Open(xlfFile, FileMode.Open);
  var fileName = Path.GetFileName(xlfFile);
  var storageResource = await crowdinApiClient.Storage.AddStorage(fileStream, filename: fileName);

  var options = new UploadTranslationsRequest()
  {
      ImportEqSuggestions = true,
      AutoApproveImported = true,
      TranslateHidden = false,
      StorageId = storageResource.Id,
  };
  var result = await crowdinApiClient.Translations.UploadTranslations(projectId, targetLanguageCode, options);

According to the documentation: FileID is only required for formats except XLIFF

andrii-bodnar commented 4 months ago

Thanks for bringing this up. We need to make the fileId parameter optional in the UploadTranslationsRequest.

adamcsillag commented 4 months ago

Hi @andrii-bodnar! The other problem is that even if I provide a valid FileId, the strings are not updated in Crowdin. The same method is working in Postman, updating the target of the strings for the referenced document.

andrii-bodnar commented 4 months ago

@adamcsillag there is probably still some difference between the Postman API call and the one made using the API client.