crowdin / crowdin-api-client-dotnet

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

`ExportProjectTranslation`: CrowdinApiException: Invalid Request Parameters: Key [format]: Value is required and can't be empty #158

Closed d2phap closed 1 year ago

d2phap commented 1 year ago

Hi,

I tried to call the ExportProjectTranslation API with the below code:

var downloadLink = await _crowdin.Translations.ExportProjectTranslation(projectId, new ExportProjectTranslationRequest()
{
    TargetLanguageId = langId,
});

I got this error:

image

Note that, I want to get the original file format so I didn't pass Format property (according to https://developer.crowdin.com/api/v2/#operation/api.projects.translations.exports.post):

Note: the format parameter is required in all cases except when you'd like to export translations for a single file in its original format

I also tried passing the format, but the TranslationFormat enum does not have the "original" option.

Please help, thank you!

andrii-bodnar commented 1 year ago

Hi @d2phap!

This API method can export only a single file in the "original" file format and in this case, you should pass the File ID in the fileIds parameter.

In case you need to export multiple files in the original format for the specified language, you should use the Build Project Translation + Check Project Build Status and Download Project Translations.

See the 6_DownloadTranslations.cs example for more details.

d2phap commented 1 year ago

Thanks @andrii-bodnar for help! It works.