title: 403 Forbibben in API Rest Call
body: <p>I am writing a small program in java which makes a rest call to an endpoint to verify a reference id. I have written this program in two different ways and each work when I run it from my PC but when I deploy the jar file on the test <code>Linux CentOs Server</code>, I get a <code>403 forbidden error</code> from the end point, So I thought maybe the ip was blocked and then I tried the same thing with curl and it worked perfectly. </p>
  
  <p>What could be the issue? could it be ssl certificate version error?</p>
  
  <p>Way 1 : </p>
  
  <pre><code>public String sendGet(String id) {
      restTemplate = new RestTemplate();
      log.info("Authorization :::: {}", "Bearer " + this.getApiAuth());
  
      HttpHeaders headers = new HttpHeaders();
  
      headers.set("Authorization", "Bearer " + this.getApiAuth());
  
      List&lt;MediaType&gt; acceptableMediaTypes = new ArrayList&lt;&gt;();
  
      acceptableMediaTypes.add(MediaType.APPLICATION_JSON);
      headers.setAccept(acceptableMediaTypes);
      headers.setContentType(MediaType.APPLICATION_JSON);
  
      HttpEntity&lt;String&gt; httpRequestEntity = new HttpEntity&lt;&gt;(headers);
      ResponseEntity&lt;String&gt; exchange = getRestTemplate().exchange(this.getUrl() + id, HttpMethod.GET, httpRequestEntity, String.class);
  
      log.info("Status Code :::: {}", exchange.getStatusCode());
      log.info("Status Code :::: {}", exchange.getBody());
      return exchange.getBody(); 
  }
  </code></pre>
  
  <p>Way 2 :</p>
  
  <pre><code> public String sendGet(String message) throws Exception {
      infoLogger.info("GOING HERE " + url + message);
  
      java.lang.System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
      URL obj = new URL(url + message);
      HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
  
      con.setRequestMethod("GET");
  
      infoLogger.info("Setting Authorization: Bearer " + this.getApiAuth());
      con.setRequestProperty("Authorization", "Bearer " +this.getApiAuth());
      con.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON_VALUE);
      con.setRequestProperty("accept", MediaType.APPLICATION_JSON_VALUE);
  
      int responseCode = con.getResponseCode();
      infoLogger.info("\nSending 'GET' request to URL : " + url);
      infoLogger.info("Response Code : " + responseCode);
  
      BufferedReader in = null;
      String inputLine;
      StringBuilder response = new StringBuilder();
  
      if ((200 &lt;= con.getResponseCode()) &amp;&amp; (con.getResponseCode() &lt;= 299)) {
          if (con.getInputStream() != null) {
              in = new BufferedReader(new InputStreamReader(con.getInputStream()));
          }
      } else if (con.getErrorStream() != null) {
          in = new BufferedReader(new InputStreamReader(con.getErrorStream()));
      } else {
          infoLogger.info("GOT NOTHING ");
      }
  
      while ((inputLine = in.readLine()) != null) {
          response.append(inputLine);
      }
      in.close();
  
      //print result
      System.out.println(response.toString());
      return response.toString();
  
  }
  </code></pre>
  
  <p>So I did a <code>.getResponseMessage</code> as asked and I got the following error:</p>
  
  <blockquote>
    <p>              Access denied | api.paystack.co used Cloudflare to restrict accessbody{margin:0;padding:0}      Please enable cookies.                  <h1>          Error          1010          Ray ID: 49f12b9b9bb6c5fa &bull; 2019-01-26 07:12:17 UTC        </h1>        Access denied                                                What happened?            <p>The owner of this website (api.paystack.co) has banned your access based on your browser's signature (49f12b9b9bb6c5fa-ua21).</p>                                          <p>    Cloudflare Ray ID: <strong>49f12b9b9bb6c5fa</strong>    &bull;    Your IP: 104.248.9.123    &bull;    Performance &amp; security by Cloudflare      </p>          window._cf_translation = {};    `</p>
  </blockquote>