Skip to content

Commit 0fc62c6

Browse files
Merge pull request #262687 from laujan/198299-update-doc-tran-code
update code samples
2 parents 2611a49 + cdc7492 commit 0fc62c6

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

articles/ai-services/translator/document-translation/how-to-guides/use-rest-api-programmatically.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: laujan
66
manager: nitinme
77
ms.service: azure-ai-translator
88
ms.topic: quickstart
9-
ms.date: 07/18/2023
9+
ms.date: 01/08/2024
1010
ms.author: lajanuar
1111
recommendations: false
1212
ms.devlang: csharp, golang, java, javascript, python
@@ -45,7 +45,7 @@ To get started, you need:
4545

4646
1. **Resource Region**. Choose **Global** unless your business or application requires a specific region. If you're planning on using a [system-assigned managed identity](create-use-managed-identities.md) for authentication, choose a **geographic** region like **West US**.
4747

48-
1. **Name**. Enter the name you have chosen for your resource. The name you choose must be unique within Azure.
48+
1. **Name**. Enter the name you chose for your resource. The name you choose must be unique within Azure.
4949

5050
> [!NOTE]
5151
> Document Translation requires a custom domain endpoint. The value that you enter in the Name field will be the custom domain name parameter for your endpoint.
@@ -56,13 +56,13 @@ To get started, you need:
5656

5757
1. Review the service terms and select **Create** to deploy your resource.
5858

59-
1. After your resource has successfully deployed, select **Go to resource**.
59+
1. After your resource successfully deploys, select **Go to resource**.
6060

6161
### Retrieve your key and custom domain endpoint
6262

6363
*Requests to the Translator service require a read-only key and custom endpoint to authenticate access. The custom domain endpoint is a URL formatted with your resource name, hostname, and Translator subdirectories and is available in the Azure portal.
6464

65-
1. If you've created a new resource, after it deploys, select **Go to resource**. If you have an existing Document Translation resource, navigate directly to your resource page.
65+
1. If you created a new resource, after it deploys, select **Go to resource**. If you have an existing Document Translation resource, navigate directly to your resource page.
6666

6767
1. In the left rail, under *Resource Management*, select **Keys and Endpoint**.
6868

@@ -76,7 +76,7 @@ To get started, you need:
7676

7777
Requests to the Translator service require a read-only key for authenticating access.
7878

79-
1. If you've created a new resource, after it deploys, select **Go to resource**. If you have an existing Document Translation resource, navigate directly to your resource page.
79+
1. If you created a new resource, after it deploys, select **Go to resource**. If you have an existing Document Translation resource, navigate directly to your resource page.
8080
1. In the left rail, under *Resource Management*, select **Keys and Endpoint**.
8181
1. Copy and paste your key in a convenient location, such as *Microsoft Notepad*.
8282
1. You paste it into the code sample to authenticate your request to the Document Translation service.
@@ -97,9 +97,9 @@ You need to [**create containers**](../../../../storage/blobs/storage-quickstar
9797

9898
The `sourceUrl` , `targetUrl` , and optional `glossaryUrl` must include a Shared Access Signature (SAS) token, appended as a query string. The token can be assigned to your container or specific blobs. *See* [**Create SAS tokens for Document Translation process**](create-sas-tokens.md).
9999

100-
* Your **source** container or blob must have designated **read** and **list** access.
101-
* Your **target** container or blob must have designated **write** and **list** access.
102-
* Your **glossary** blob must have designated **read** and **list** access.
100+
* Your **source** container or blob must designate **read** and **list** access.
101+
* Your **target** container or blob must designate **write** and **list** access.
102+
* Your **glossary** blob must designate **read** and **list** access.
103103

104104
> [!TIP]
105105
>
@@ -142,11 +142,11 @@ The following headers are included with each Document Translation API request:
142142
"inputs": [
143143
{
144144
"source": {
145-
"sourceUrl": "https://my.blob.core.windows.net/source-en?sv=2019-12-12&st=2021-03-05T17%3A45%3A25Z&se=2021-03-13T17%3A45%3A00Z&sr=c&sp=rl&sig=SDRPMjE4nfrH3csmKLILkT%2Fv3e0Q6SWpssuuQl1NmfM%3D"
145+
"sourceUrl": "{sourceSASUrl}"
146146
},
147147
"targets": [
148148
{
149-
"targetUrl": "https://my.blob.core.windows.net/target-fr?sv=2019-12-12&st=2021-03-05T17%3A49%3A02Z&se=2021-03-13T17%3A49%3A00Z&sr=c&sp=wdl&sig=Sq%2BYdNbhgbq4hLT0o1UUOsTnQJFU590sWYo4BOhhQhs%3D",
149+
"targetUrl": "{targetSASUrl}",
150150
"language": "fr"
151151
}
152152
]
@@ -158,8 +158,8 @@ The following headers are included with each Document Translation API request:
158158
### Translate a specific document in a container
159159

160160
* Specify `"storageType": "File"`
161-
* If you aren't using a [**system-assigned managed identity**](create-use-managed-identities.md) for authentication, make sure you've created source URL & SAS token for the specific blob/document (not for the container)
162-
* Ensure you've specified the target filename as part of the target URL – though the SAS token is still for the container.
161+
* If you aren't using a [**system-assigned managed identity**](create-use-managed-identities.md) for authentication, make sure you created source URL & SAS tokens for the specific blob/document (not for the container)
162+
* Ensure you specified the target filename as part of the target URL – though the SAS token is still for the container.
163163
* This sample request returns a single document translated into two target languages
164164

165165
```json
@@ -168,15 +168,15 @@ The following headers are included with each Document Translation API request:
168168
{
169169
"storageType": "File",
170170
"source": {
171-
"sourceUrl": "https://my.blob.core.windows.net/source-en/source-english.docx?sv=2019-12-12&st=2021-01-26T18%3A30%3A20Z&se=2021-02-05T18%3A30%3A00Z&sr=c&sp=rl&sig=d7PZKyQsIeE6xb%2B1M4Yb56I%2FEEKoNIF65D%2Fs0IFsYcE%3D"
171+
"sourceUrl": "{sourceSASUrl}"
172172
},
173173
"targets": [
174174
{
175-
"targetUrl": "https://my.blob.core.windows.net/target/try/Target-Spanish.docx?sv=2019-12-12&st=2021-01-26T18%3A31%3A11Z&se=2021-02-05T18%3A31%3A00Z&sr=c&sp=wl&sig=AgddSzXLXwHKpGHr7wALt2DGQJHCzNFF%2F3L94JHAWZM%3D",
175+
"targetUrl": "{targetSASUrl}",
176176
"language": "es"
177177
},
178178
{
179-
"targetUrl": "https://my.blob.core.windows.net/target/try/Target-German.docx?sv=2019-12-12&st=2021-01-26T18%3A31%3A11Z&se=2021-02-05T18%3A31%3A00Z&sr=c&sp=wl&sig=AgddSzXLXwHKpGHr7wALt2DGQJHCzNFF%2F3L94JHAWZM%3D",
179+
"targetUrl": "{targetSASUrl}",
180180
"language": "de"
181181
}
182182
]
@@ -192,15 +192,15 @@ The following headers are included with each Document Translation API request:
192192
"inputs": [
193193
{
194194
"source": {
195-
"sourceUrl": "https://myblob.blob.core.windows.net/source"
195+
"sourceUrl": "{sourceSASUrl}"
196196
},
197197
"targets": [
198198
{
199-
"targetUrl": "https://myblob.blob.core.windows.net/target",
199+
"targetUrl": "{targetSASUrl}",
200200
"language": "es",
201201
"glossaries": [
202202
{
203-
"glossaryUrl": "https:// myblob.blob.core.windows.net/glossary/en-es.xlf",
203+
"glossaryUrl": "{glossaryUrl/en-es.xlf}",
204204
"format": "xliff"
205205
}
206206
]
@@ -1097,7 +1097,7 @@ func main() {
10971097

10981098
### Brief overview
10991099

1100-
Cancel currently processing or queued job. Only documents for which translation hasn't started are canceled.
1100+
Cancel currently processing or queued job. Only documents for which translation isn't started are canceled.
11011101

11021102
### [C#](#tab/csharp)
11031103

@@ -1280,8 +1280,8 @@ func main() {
12801280
| 200 | OK | The request was successful. |
12811281
| 400 | Bad Request | A required parameter is missing, empty, or null. Or, the value passed to either a required or optional parameter is invalid. A common issue is a header that is too long. |
12821282
| 401 | Unauthorized | The request isn't authorized. Check to make sure your key or token is valid and in the correct region. When managing your subscription on the Azure portal, make sure you're using the **Translator** single-service resource _not_ the **Azure AI services** multi-service resource.
1283-
| 429 | Too Many Requests | You've exceeded the quota or rate of requests allowed for your subscription. |
1284-
| 502 | Bad Gateway | Network or server-side issue. May also indicate invalid headers. |
1283+
| 429 | Too Many Requests | You exceeded the quota or rate of requests allowed for your subscription. |
1284+
| 502 | Bad Gateway | Network or server-side issue. Can also indicate invalid headers. |
12851285

12861286
## Learn more
12871287

0 commit comments

Comments
 (0)