Deep Translate

부분 유료
분류별 Serge | 업데이트됨 5 days ago | Translation
인기

9.9 / 10

지연 시간

1,399ms

서비스 수준

98%

Health Check

N/A

모든 토론으로 돌아가기

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?

아래에 의견을 추가하고 토론에 참여하세요.

새 댓글을 게시하려면 로그인 / 가입