Receiving 403 Forbidden Response While Implementing RapidAPI on Android Studio

I’m trying to integrate the Twinword dictionary API into my Android Studio project, but I’m encountering a 403 Forbidden error. Here’s the code I’m using:

RapidApiConnector connector = new RapidApiConnector("Insert your project name here", "Where do I locate the project key?");
String resultData;

String apiHost = "twinword-twinword-bundle-v1.p.rapidapi.com";
String API_KEY = "your_api_key_here";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    resultData = getIntent().getStringExtra("ObjectName");
    Log.d("DEBUG_LOG", resultData);
    OkHttpClient client = new OkHttpClient();

    Request request = new Request.Builder()
            .url("https://twinword-twinword-bundle-v1.p.rapidapi.com/word_example/?entry=mask")
            .get()
            .addHeader("x-rapidapi-host", apiHost)
            .addHeader("x-rapidapi-key", API_KEY)
            .build();

    client.newCall(request).enqueue(new Callback() {
        @Override
        public void onFailure(Request request, IOException error) {
            Log.d("DEBUG_LOG", "Request failed");
            error.printStackTrace();
        }

        @Override
        public void onResponse(Response response) throws IOException {
            Log.d("DEBUG_LOG", "Received response");

            try (ResponseBody body = response.body()) {
                if (!response.isSuccessful()) {
                    Log.d("DEBUG_LOG", "Unexpected response code");
                    throw new IOException("Unexpected code: " + response);
                }

                Headers responseHeaders = response.headers();
                Log.d("DEBUG_LOG", "Response headers");
                for (int i = 0; i < responseHeaders.size(); i++) {
                    System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
                }

                System.out.println(body.string());
            }
        }
    });
}

I think the error might be due to not having the correct Project Key because I’m unable to find it on the RapidAPI site. Additionally, I’m uncertain if my code setup has any issues. This is my first experience with API integrations, and I’d appreciate any help I can get.

yep, that api key is just a placeholder. u gotta put the real one from your rapidapi dashboard in there instead. also, maybe skip the RapidApiConnector bit and go straight for the okhttp request.

You’re using placeholder values in your API key field. Go to your RapidAPI dashboard, find your Twinword API subscription, and grab the actual X-RapidAPI-Key from the code snippets section. Replace “your_api_key_here” with that real key.

I’ve hit the same authentication issues when starting with RapidAPI. You don’t need that RapidApiConnector initialization at the top since you’re doing HTTP requests manually with OkHttp. Just delete those connector lines.

Here’s a debugging trick that saved me - add response code logging before your isSuccessful check. Drop in Log.d("DEBUG_LOG", "Response code: " + response.code()); to see what status you’re actually getting. RapidAPI throws different error codes that’ll tell you if it’s auth problems or quota limits.

That 403 error is happening because you’re mixing two different approaches. Drop the RapidApiConnector since you’re using OkHttp directly.

Delete this line:

RapidApiConnector connector = new RapidApiConnector("Insert your project name here", "Where do I locate the project key?");

Replace “your_api_key_here” with your actual RapidAPI key. Go to rapidapi.com, log in, click your app, and grab the X-RapidAPI-Key value.

I’ve been through similar API integration nightmares. What changed everything for me was switching to automation tools that handle this mess.

Skip wrestling with Android HTTP clients and API keys. Set up Latenode to handle the dictionary API calls instead. It connects to RapidAPI services without code, then sends results to your Android app through webhooks or a simple REST endpoint.

Your app just makes one clean request to your Latenode workflow, and it handles all the RapidAPI authentication and error handling automatically.