Server bases TMs problem - cannot authorize properly when using SDK

Hi, 

I am unable to run some automatic tasks using API. Error in trados on screen below.

Screenshot of Studio Developers Q&A error dialog with multiple error messages. The first error is 'Unexpected exception when configuring the API...' related to Translation Memory configuration. Other errors are stack traces indicating issues with 'TranslationProviderCascadeEntry' and 'TranslationProviderReference'.

Code adding TM to the project is as below:

{code}

TranslationProviderConfiguration tmConf = fileBasedProject.GetTranslationProviderConfiguration(projectTargetLanguage);
tmConf.OverrideParent = true;

TranslationMemoryIdentification identification = getById(new Guid(resource.id), apiUrl, userName,
password);
var normalizedUri = apiUrl.TrimEnd(new char[] {'/'});

tmConf.Entries.Add(
(
new TranslationProviderCascadeEntry
(
new TranslationProviderReference(new Uri(String.Format("sdltm.{0}?orgPath={1}&tmName={2}", normalizedUri, identification.organization, identification.name))),
true,
true,
true,
0
)
));
string credential = String.Format("user={0};password={1};type=CustomUser", userName, password);
log.Info("Credential:" + credential);
fileBasedProject.Credentials.AddCredential(new Uri("sdltm."+apiUrl), credential);
fileBasedProject.UpdateTranslationProviderConfiguration(projectTargetLanguage, tmConf);
fileBasedProject.Save();

{code}

However if I skip this task, and run it in Trados, then all works fine.

What am I doing wrong here ?



Generated Image Alt-Text
[edited by: RWS Community AI at 6:45 AM (GMT 0) on 15 Nov 2024]
Parents Reply Children
  • You are right, this code runs perfectly.
    It is because it is performed in one go.

    However our architecture is different. It enables you to create project in one process, after some time add some TMs in another process, and then runs another one just to perform some tasks. And it looks like in this scenario these credentials are lost, and 3rd process returns an error.

    Can you tell me why this happens ? Why FileBasedProject does remember TM entries, but forgets credentials to them ?

    ANyway thanks for your help, thanks to this we are able to create some workaround for this (we add credentials once again each time we run automated tasks)