Pushing HTML files for automatic Project creation in Trados

Please see case CS0050244

This particular query concerns sending HTML files to Trados to automatically create a project using a certain template. We extract HTML files from an email campaign site and inject the translated versions back for automated population. The missing link to fully automate our workflow is getting Trados to automatically create a project with SDLXLIFF files. 

Parents
  • Hi ,

    The missing link you're describing is the Trados Studio ProjectAutomation API, which lets you programmatically create projects from a template.

    Here's the approach:

    1. Use the FileBasedProject class from the Sdl.ProjectAutomation.FileBased namespace to create a new project based on an existing template (.sdltpl file).
    2. Pass your HTML source files as input — make sure your template already has the HTML file type configured with the correct parsing settings.
    3. The SDLXLIFF files will be generated in the project folder.

    A minimal example in C# can be found here.

    Hope this helps!

  • Hello Emanuel, 

    Thanks a lot for your response. I will try it out today. 

  • Hello Emanuel, 

    After review of the solutions sent it seems a looking for something a little bit different. I am not trying to automate the local desktop client. I am building a cloud-to-cloud integration using the Trados Language Cloud REST API, but your EU server (eu.cloud.trados.com) is returning a 500 Internal Server Error for my Tenant ID. 

  • Hello Jose,

    I think you should look into the Postman collection for the API:

    Trados Cloud Platform APIs for Postman

    You will need to

    1. have one user with API rights
    2. create an API key for this user
    3. use the API to create a "bearer token" before performing any real action.

    Example:

    private async Task<string> GetBearer()
    {
    var options = new RestClientOptions("">sdl-prod.eu.auth0.com")
    {
    Timeout=new TimeSpan(1,0,0,0)
    };
    var client = new RestClient(options);
    var request = new RestRequest("/oauth/token", Method.Post);
    request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
    request.AddHeader("Cookie", [check your own cookie value using Postman]);
    request.AddParameter("client_id", [as created with your API key]);
    request.AddParameter("client_secret", [as created with your API key]);
    request.AddParameter("grant_type", "client_credentials");
    request.AddParameter("audience", "">https://api.sdl.com");
    RestResponse response = await client.ExecuteAsync(request);
    return response.Content;
    }

    Call this async Task from somewhere else:

    Token = GetBearer().Result;

    To get project information with given project id:

    private async Task GetProject(string token, string pid)
    {
    var options = new RestClientOptions("">https://lc-api.sdl.com")
    {
    Timeout=new TimeSpan(1,0,0,0)
    };
    var client = new RestClient(options);
    var request = new RestRequest($"/public-api/v1/projects/{pid}", Method.Get);
    request.AddHeader("X-LC-Tenant", [tenant id goes here]);
    request.AddHeader("Accept", "application/json");
    request.AddHeader("Authorization", $"Bearer {token}");
    RestResponse response = await client.ExecuteAsync(request);
    ProjectData = response.Content;
    }

    This example if for reading project information. To create projects:

    Create projects

    Hope this helps!

    Best regards,
    Andreas

Reply
  • Hello Jose,

    I think you should look into the Postman collection for the API:

    Trados Cloud Platform APIs for Postman

    You will need to

    1. have one user with API rights
    2. create an API key for this user
    3. use the API to create a "bearer token" before performing any real action.

    Example:

    private async Task<string> GetBearer()
    {
    var options = new RestClientOptions("">sdl-prod.eu.auth0.com")
    {
    Timeout=new TimeSpan(1,0,0,0)
    };
    var client = new RestClient(options);
    var request = new RestRequest("/oauth/token", Method.Post);
    request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
    request.AddHeader("Cookie", [check your own cookie value using Postman]);
    request.AddParameter("client_id", [as created with your API key]);
    request.AddParameter("client_secret", [as created with your API key]);
    request.AddParameter("grant_type", "client_credentials");
    request.AddParameter("audience", "">https://api.sdl.com");
    RestResponse response = await client.ExecuteAsync(request);
    return response.Content;
    }

    Call this async Task from somewhere else:

    Token = GetBearer().Result;

    To get project information with given project id:

    private async Task GetProject(string token, string pid)
    {
    var options = new RestClientOptions("">https://lc-api.sdl.com")
    {
    Timeout=new TimeSpan(1,0,0,0)
    };
    var client = new RestClient(options);
    var request = new RestRequest($"/public-api/v1/projects/{pid}", Method.Get);
    request.AddHeader("X-LC-Tenant", [tenant id goes here]);
    request.AddHeader("Accept", "application/json");
    request.AddHeader("Authorization", $"Bearer {token}");
    RestResponse response = await client.ExecuteAsync(request);
    ProjectData = response.Content;
    }

    This example if for reading project information. To create projects:

    Create projects

    Hope this helps!

    Best regards,
    Andreas

Children