Skip to main content

Remove and add object's translations

This topic covers workflow for removing and adding object's translations.

Endpoint PATCH /api/objects/{type}/{id}/translation.

The response can change based on the request parameters provided by the caller. Use the following parameters:

LocationNameDescription
headerX-MSTR-AuthTokenThe authorization token
headerX-MSTR-ProjectIDThe ID of the project
pathobjectIdId of an object
pathtypeType of an object
bodyoperationListList of operations to be done

The following table lists important fields in the API request body:

FieldDescription
operationListList of operations to be performed
opOperation to be performed for a translation. Available values: "add", "replace", "remove"
pathPath within a body structure to place of modification. available value for:
add operation: "/localesAndTranslations/{targetNameId}/translationValues",
remove operation:"/localesAndTranslations/{targetNameId}/translationValues/{localeId}"
valueNew value - used only for "replace" and "add" operations

Prepare necessary info in order to perform PATCH operation

info

All params, but the request body are common for both 'add' and 'replace' operations

  1. Get the authorization token needed to execute the request with POST /api/auth/login.
  2. Get the project ID from GET /api/projects.
  3. Identify the object type from EnumDSSXMLObjectTypes.
  4. Prepare request body. For this purpose, call GET /api/objects/{type}/{id}/translations.

In this demo following parameter values will be used:

  • Project: MicroStrategy Tutorial
  • Project ID: B7CA92F04B9FAE8D941C3E9B7E0CD754
  • Object ID: BEC722A6406320A3E67DBFBAB2F033CB
  • Object type: report_definition

Request URL:

https://demo.microstrategy.com/MicroStrategyLibrary/api/objects/report_definition/BEC722A6406320A3E67DBFBAB2F033CB/translations
info

Multiple different operations can be performed within one request, however in this sample there will be only one modification in one request.

Remove object's translations

Request body:

{
"operationList": [
{
"op": "remove",
"path": "/localesAndTranslations/1:0:/translationValues/1040"
}
]
}

Sample Curl:

curl -X 'PATCH' \
'https://demo.microstrategy.com/MicroStrategyLibrary/api/objects/report_definition/BEC722A6406320A3E67DBFBAB2F033CB/translations' \
-H 'accept: application/json' \
-H 'X-MSTR-AuthToken: h6qf9oieijrrfut5k562r4s05k' \
-H 'X-MSTR-ProjectID: B7CA92F04B9FAE8D941C3E9B7E0CD754' \
-H 'Content-Type: application/json' \
-d '{
"operationList": [
{
"op": "remove",
"path": "/localesAndTranslations/1:0:/translationValues/1040"
}
]
}'

Sample Response Body:

{
"defaultLanguage": "en",
"localesAndTranslations": {
"1:0:": {
"translationTargetName": "Object Name ",
"translationValues": {
"1028": {
"translation": "產品大類銷售報表"
},
"1031": {
"translation": "Kategorieumsatzbericht"
},
"1033": {
"translation": "Category Sales Report"
},
"1036": {
"translation": "Rapport sur les ventes par catégorie"
},
"1041": {
"translation": "カテゴリ売上レポート"
},
"1042": {
"translation": "범주 매출 리포트"
},
"1046": {
"translation": "Relatório de Vendas da Categoria"
},
"1053": {
"translation": "Kategoriförsäljningsrapport"
},
"2052": {
"translation": "各大类商品销售报表"
},
"3082": {
"translation": "Categoría Informe de ventas"
}
}
},
"1:2:": {
"translationTargetName": "Object Description ",
"translationValues": {
"1028": {
"translation": "該報表顯示了某特定產品類別和中類每月的營收和利潤資訊。該利息的產品類別通過分頁選擇。"
},
"1031": {
"translation": "Dieser Bericht zeigt Informationen zu Einnahmen und Gewinn nach Monat für eine bestimmte Kategorie und Subkategorie. Die Kategorie, für die Sie sich interessieren, wird mit Page-By ausgewählt."
},
"1033": {
"translation": "This report displays revenue and profit information by month for a particular category and subcategory. The category of interest is selected via page-by."
},
"1036": {
"translation": "Ce rapport affiche les informations sur le chiffre d'affaires et le profit par mois pour une certaine catégorie et sous-catégorie La catégorie qui intéresse l'utilisateur est sélectionnée via le saut de page."
},
"1040": {
"translation": "Questo report mostra informazioni di entrate e profitti per mese per categorie e sottocategorie particolari. La categoria di interesse viene selezionata tramite raggruppamento a pagine."
},
"1041": {
"translation": "このレポートは特定のカテゴリとサブカテゴリごとに月別で売上高と利益情報を示します。カテゴリはページバイで選択できます。"
},
"1042": {
"translation": "이 리포트는 특정 범주 및 하위 범주별로 월별 수익 및 이익 정보를 표시합니다. 원하는 범주는 페이지-바이를 통해 선택됩니다."
},
"1046": {
"translation": "Este relatório exibe informações sobre a receita e o lucro mensal de categorias e subcategorias específicas. A categoria de interesse é selecionada página a página."
},
"1053": {
"translation": "Denna rapport visar information om intäkt och vinst per månad för en viss kategori och underkategori. Kategorin av intresse väljs genom sökning."
},
"2052": {
"translation": "该报表显示了某特定商品大类和子类每月的收益和利润信息。该利息的商品大类通过分页选择。"
},
"3082": {
"translation": "Este informe muestra información sobre ingresos y beneficios por mes para una categoría y una subcategoría determinadas. La categoría se selecciona mediante paginación."
}
}
}
}
}

Response Code: 200 (Object's translations returned successfully)

Add object's translations

Request body:

{
"operationList": [
{
"op": "add",
"path": "/localesAndTranslations/1:0:/translationValues",
"value": {
"1040": {
"translation": "added translation"
}
}
}
]
}

Sample curl:

curl -X 'PATCH' \
'https://demo.microstrategy.com/MicroStrategyLibrary/api/objects/report_definition/BEC722A6406320A3E67DBFBAB2F033CB/translations' \
-H 'accept: application/json' \
-H 'X-MSTR-AuthToken: h6qf9oieijrrfut5k562r4s05k' \
-H 'X-MSTR-ProjectID: B7CA92F04B9FAE8D941C3E9B7E0CD754' \
-H 'Content-Type: application/json' \
-d '{
"operationList": [
{
"op": "add",
"path": "/localesAndTranslations/1:0:/translationValues",
"value":
{ "1040":
{
"translation": "added translation"
}
}
}
]
}'

Sample response body:

{
"defaultLanguage": "en",
"localesAndTranslations": {
"1:0:": {
"translationTargetName": "Object Name ",
"translationValues": {
"1028": {
"translation": "產品大類銷售報表"
},
"1031": {
"translation": "Kategorieumsatzbericht"
},
"1033": {
"translation": "Category Sales Report"
},
"1036": {
"translation": "Rapport sur les ventes par catégorie"
},
"1040": {
"translation": "added translation"
},
"1041": {
"translation": "カテゴリ売上レポート"
},
"1042": {
"translation": "범주 매출 리포트"
},
"1046": {
"translation": "Relatório de Vendas da Categoria"
},
"1053": {
"translation": "Kategoriförsäljningsrapport"
},
"2052": {
"translation": "各大类商品销售报表"
},
"3082": {
"translation": "Categoría Informe de ventas"
}
}
},
"1:2:": {
"translationTargetName": "Object Description ",
"translationValues": {
"1028": {
"translation": "該報表顯示了某特定產品類別和中類每月的營收和利潤資訊。該利息的產品類別通過分頁選擇。"
},
"1031": {
"translation": "Dieser Bericht zeigt Informationen zu Einnahmen und Gewinn nach Monat für eine bestimmte Kategorie und Subkategorie. Die Kategorie, für die Sie sich interessieren, wird mit Page-By ausgewählt."
},
"1033": {
"translation": "This report displays revenue and profit information by month for a particular category and subcategory. The category of interest is selected via page-by."
},
"1036": {
"translation": "Ce rapport affiche les informations sur le chiffre d'affaires et le profit par mois pour une certaine catégorie et sous-catégorie La catégorie qui intéresse l'utilisateur est sélectionnée via le saut de page."
},
"1040": {
"translation": "Questo report mostra informazioni di entrate e profitti per mese per categorie e sottocategorie particolari. La categoria di interesse viene selezionata tramite raggruppamento a pagine."
},
"1041": {
"translation": "このレポートは特定のカテゴリとサブカテゴリごとに月別で売上高と利益情報を示します。カテゴリはページバイで選択できます。"
},
"1042": {
"translation": "이 리포트는 특정 범주 및 하위 범주별로 월별 수익 및 이익 정보를 표시합니다. 원하는 범주는 페이지-바이를 통해 선택됩니다."
},
"1046": {
"translation": "Este relatório exibe informações sobre a receita e o lucro mensal de categorias e subcategorias específicas. A categoria de interesse é selecionada página a página."
},
"1053": {
"translation": "Denna rapport visar information om intäkt och vinst per månad för en viss kategori och underkategori. Kategorin av intresse väljs genom sökning."
},
"2052": {
"translation": "该报表显示了某特定商品大类和子类每月的收益和利润信息。该利息的商品大类通过分页选择。"
},
"3082": {
"translation": "Este informe muestra información sobre ingresos y beneficios por mes para una categoría y una subcategoría determinadas. La categoría se selecciona mediante paginación."
}
}
}
}
}

Response Code: 200 (Object's translations returned successfully)