Cannot cancel a translation with Document Translation REST API

OscarMucchiati-5816 1 Reputation point
2021-11-17T15:49:17.58+00:00

I have submitted a translation job using Document Translation REST API. The source blobs container has 6 documents.
The job was almost done, just 1 document is flagged as "Running".
This process seems to keep on going forever, so I wanted to cancel that translation job.

This is a sample of the code I've used:

using (var client = new HttpClient())
using (var request = new HttpRequestMessage())
{
    request.Method = HttpMethod.Delete;
    request.RequestUri = new Uri(endpoint + $"/batches/{jobID}");
    request.Headers.Add("Ocp-Apim-Subscription-Key", subscriptionKey);

    HttpResponseMessage response = await client.SendAsync(request);
    string result = response.Content.ReadAsStringAsync().Result;
}

This is the response I get:

{
  "id": "######JOBID######",
  "createdDateTimeUtc": "2021-11-16T23:37:34.4858336Z",
  "lastActionDateTimeUtc": "2021-11-16T23:37:48.6257997Z",
  "status": "Running",
  "summary": {
    "total": 6,
    "failed": 0,
    "success": 5,
    "inProgress": 1,
    "notYetStarted": 0,
    "cancelled": 0,
    "totalCharacterCharged": 56060
  }
}

The translation keeps "running" on this single document, indefinitely.

What can I do? Is there something wrong with my code?

Thanks.

Azure Translator
Azure Translator
An Azure service to easily conduct machine translation with a simple REST API call.
441 questions
{count} votes

1 answer

Sort by: Most helpful
  1. YutongTie-MSFT 53,871 Reputation points
    2021-11-18T03:25:07.683+00:00

    Hello,

    You can try to cancel the running job and retry again.

    How to can cancel a running job: https://learn.microsoft.com/en-us/azure/cognitive-services/translator/document-translation/reference/cancel-translation

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.