Skip to Content

Use the Machine Translation API from a REST Client

test
0 %
Use the Machine Translation API from a REST Client
Details
// Explore More Tutorials

Use the Machine Translation API from a REST Client

11/16/2018

Discover how to call the Machine Translation API from a REST Client like Postman

You will learn

  • Call an API from a REST client like Postman
  • The basics about Machine Learning Foundation Service for Machine Translation

Note: This service was in alpha version when this tutorial was released.

Step 1: The Machine Translation Service

The Machine Translation service enables you to translate texts into a range of languages.

This service is powered by SAP Translation Hub and is trained on SAP-related content to provide accurate domain adaptation and terminology coverage.

The service execution requires the following details provided using the request body in a JSON format:
- the source language
- the target languages (one or more)
- a series of input texts with an associated key identifier

The service will return a JSON response that includes the original input text with the associated translations.

For more details, you can check the Inference Service for Machine Translation on the SAP API Business Hub.

Log on to answer question
Step 2: Call the API

Open a new tab in Postman.

Make sure that the my-l-foundation environment is selected.

On the Authorization tab, select Bearer Token, then enter {{OAuthToken}} as value.

Postman

Note:: the OAuthToken environment variable can be retrieved following the Get your OAuth Access Token using a REST Client tutorial.

Fill in the following additional information:

Field Name Value
HTTP Method POST
URL https://mlftrial-machine-translation.cfapps.eu10.hana.ondemand.com/api/v2/text/translation

Note As a reminder, the URL depends on you Cloud Platform landscape region but for the trial landscape only Europe (Frankfurt) provide access to the Machine Learning Foundation services.

On the Body tab, select raw then select JSON (application/json) instead of Text.

And in the body area paste the following content:

{
  "sourceLanguage": "de",
  "targetLanguages": [
    "en"
  ],
  "units": [
    {
      "value": "Ich möchte meine Verkaufsdaten analysieren.",
      "key": "ANALYZE_SALES_DATA"
  	},
	{
      "value": "Ich möchte einen Bericht mit meinen vierteljährlichen Umsatzdaten erstellen",
      "key": "REPORT_QUARTERLY_REVENUE"
    }
  ]
}

This will translate the 2 units in English from German.

Postman

Click on Send.

You should receive a response that includes a series of faces entries:

Postman
{
    "value": "Ich möchte meine Verkaufsdaten analysieren.",
    "key": "ANALYZE_SALES_DATA",
    "translations": [
        {
            "language": "en",
            "value": "I want to analyze my sales data."
        }
    ]
}
Log on to answer question
Step 3: Validate your results

Provide an answer to the question below then click on Validate.

Paste the full response returned with the previous test.
×

Next Steps

Back to top