Bing Translator throws StatusCodeError: 400 - {"error":{"code":400005,"message":"The input text is not valid." for an input of 2501 characters

Ashish Dwivedi 1 Reputation point
2020-08-19T10:19:07.917+00:00

I understand that the character limit for a single translation query is 10000 characters overall (including the response for all the queried languages).
I am querying the bing translator to translate large paragraph as input. Everything works fine till 2500 characters, but anything more than that, starts throwing the error StatusCodeError: 400 - {"error":{"code":400005,"message":"The input text is not valid.
Noteworthy thing here is that the translate operation fails even if it is queried for one language, which should not be the case, as the total of input the response would only amount to 5002 characters (in case of 2501 character input) which is half of the permissible character limit.
Not sure where I'm going wrong with this.

Below is a sample of the input I'm providing:
As they rounded a bend in the path that ran beside the river, Lara recognized the silhouette of a fig tree atop a nearby hill. The weather was hot and the days were long. The fig tree was in full leaf, but not yet bearing fruit.↵Soon Lara spotted other landmarks—an outcropping of limestone beside the path that had a silhouette like a man’s face, a marshy spot beside the river where the waterfowl were easily startled, a tall tree that looked like a man with his arms upraised. They were drawing near to the place where there was an island in the river. The island was a good spot to make camp. They would sleep on the island tonight.↵Lara had been back and forth along the river path many times in her short life. Her people had not created the path—it had always been there, like the river—but their deerskin-shod feet and the wooden wheels of their handcarts kept the path well worn. Lara’s people were salt traders, and their livelihood took them on a continual journey.↵At the mouth of the river, the little group of half a dozen intermingled families gathered salt from the great salt beds beside the sea. They groomed and sifted the salt and loaded it into handcarts. When the carts were full, most of the group would stay behind, taking shelter amid rocks and simple lean-tos, while a band of fifteen or so of the heartier members set out on the path that ran alongside the river.↵With their precious cargo of salt, the travelers crossed the coastal lowlands and traveled toward the mountains. But Lara’s people never reached the mountaintops; they traveled only as far as the foothills. Many people lived in the forests and grassy meadows of the foothills, gathered in small villages. In return for salt, these people would give Lara’s people dried meat, animal skins, cloth spun from wool, clay pots, needles and scraping tools carved from bone, and little toys made of wood.↵Their bartering done, Lara and her people would travel back down the river path to the sea. The cycle would begin again.↵It had always been like this. Lara knew no other life. She traveled back and forth, up and down the river path. No single place was home. She liked the seaside, where there was always fish to eat, and the gentle lapping of the waves lulled her to sleep at night. She was less fond of the foothills, where the path grew steep, the nights could be cold, and views of great distances made her dizzy. She felt uneasy in the villages, and was often shy around strangers. The path itself was where

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,096 questions
Azure Translator
Azure Translator
An Azure service to easily conduct machine translation with a simple REST API call.
411 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,897 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. romungi-MSFT 46,831 Reputation points Microsoft Employee
    2020-08-19T13:29:29.88+00:00

    @Ashish Dwivedi I have used the text mentioned above with the translate API and tried to translate it to 4 different languages since the number of characters are exactly 2500 in the above text. Here is a screen shot of the request and response i received.

    18813-image.png

    When I try to add another language to the query the request fails instantly as the limit exceeds 10k

    18871-image.png

    As per this behavior the API response is according to the defined limits. The pricing tier i am using is standard S1.

    The only time the request failed for me was when the copy of this introduced some junk characters which i removed it by copying the text to notepad first and then included in my request. Could you please try to check this scenario and correct any issues in the text as the response you received mentions invalid input text.


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.