Google Translate

FREEMIUM
By Google Cloud | Updated 16 days ago | Text Analysis
Popularity

9.9 / 10

Latency

480ms

Service Level

100%

Health Check

N/A

Back to All Discussions

Getting 403 error. Shocking and disappointing

Rapid account: Bismoy
bismoy
4 years ago

import java.io.IOException;

import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;

public class Test {
public static void main(String args[]) throws IOException {
OkHttpClient client = new OkHttpClient();

	MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
	RequestBody body = RequestBody.create(mediaType, "source=en&q=Hello%2C%20world!&target=es");
	Request request = new Request.Builder().url("https://google-translate1.p.rapidapi.com/language/translate/v2")
			.post(body).addHeader("x-rapidapi-host", "google-translate1.p.rapidapi.com")
			.addHeader("x-rapidapi-key", "ea255af93fmsh4ac35f6a83472adp1b5328jsne60af6a2b885")
			.addHeader("accept-encoding", "application/gzip")
			.addHeader("content-type", "application/x-www-form-urlencoded")
			.build();

	Response response = client.newCall(request).execute();
	System.out.println(response.message());
}

}

Rapid account: Ravik 2492
ravik2492 Commented 3 years ago

same here 403 error very disappointing

Rapid account: Rapid Alex
RapidAlex Commented 4 years ago

Hey folks, could you try removing the .addHeader("accept-encoding", "application/gzip") from the request? We’ve been noticing some issues with a few APIs on the platform that utilize gzip encoding.

Rapid account: Ekoremdev
ekoremdev Commented 4 years ago

same error here. i receive 403 error on my first use of api endpoint.

Rapid account: Ekoremdev
ekoremdev Commented 4 years ago

same error here. i receive 403 error on my first use of api endpoint.

Join in the discussion - add comment below:

Login / Signup to post new comments