Deep Translate

FREEMIUM
Durch Serge | Aktualisiert 4 days ago | Translation
Popularität

9.9 / 10

Latenz

1,405ms

Service Level

98%

Health Check

N/A

Zurück zu allen Diskussionen

Response status code does not indicate success: 501 (Not Implemented)

Rapid account: Neo 1992
neo1992
2 years ago

I’m trying to implement this language detection API: https://rapidapi.com/gatzuma/api/deep-translate1
I’m subscribed to “Ultra”, so language detection should be included. I’m also noticing that the rapidapi playground throws a “400 Bad Request” error when trying to test it.

I’ve been using this API successfully for my regular translations, but when I use pretty much the same code to call the detect endpoint, I’m getting a 501 error:

Response status code does not indicate success: 501 (Not Implemented)… txt:hello world

But I have no idea what I’m doing wrong, as my code looks exactly like what they request body should be:

Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq

Protected Async Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
	ltStatus.Text = Await detectLanguage("hello world")
End Sub

Protected Async Function detectLanguage(ByVal txt As String) As Threading.Tasks.Task(Of String)
	Dim client As System.Net.Http.HttpClient = New HttpClient
	Dim request As New HttpRequestMessage
	With request
		.Method = HttpMethod.Post
		.RequestUri = New Uri("https://deep-translate1.p.rapidapi.com/language/translate/v2/detect")
		.Headers.Add("x-rapidapi-host", "deep-translate1.p.rapidapi.com")
		.Headers.Add("x-rapidapi-key", "<MY NOW MASKED API KEY HERE >")
		.Content = New StringContent("{""q"": """ + txt + """}")
	End With

	Dim detectedLang1 As String = ""
	Using response = Await client.SendAsync(request)
		response.EnsureSuccessStatusCode()
		Dim body As String = Await response.Content.ReadAsStringAsync

		Dim obj As JObject = JObject.Parse(body)
		detectedLang1 = obj("data")("detections")(0)("language").ToString
	End Using

	Return detectedLang1
End Function

What’s going on?

Nehmen Sie an der Diskussion teil - fügen Sie unten einen Kommentar hinzu:

Anmelden / Registrieren, um neue Kommentare zu veröffentlichen