title: java getting error 403 on calling web service
body: <p>I am newbie to java.I am calling webservice and getting error 403 through java,but when i call through curl it's working.here is my code for curl</p>
  
  <pre><code>$ curl -v -H "Accept: application/json" -H "Content-type: application/json" \
         -X GET  https://openapi.etsy.com/v2/categories/jewelry?api_key={api_key}
  </code></pre>
  
  <p>Here is Java Code:</p>
  
  <pre><code>try {
  
          URL url = new URL("https://openapi.etsy.com/v2/listings/active?api_key={api_key}");
          System.out.println(url.toString());
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("GET");
          conn.setDoOutput(true);
          conn.setRequestProperty("Content-Type", "application/json");
          //conn.setRequestProperty("charset", "utf-8");
          conn.setRequestProperty("Accept", "application/json");  
  
          if (conn.getResponseCode() != 200) {
              throw new RuntimeException("Failed : HTTP error code : "
                      + conn.getResponseCode());
          }
  
          BufferedReader br = new BufferedReader(new InputStreamReader(
              (conn.getInputStream())));
  
          String output;
          System.out.println("Output from Server .... \n");
          while ((output = br.readLine()) != null) {
              System.out.println(output);
          }
  
          conn.disconnect();
  
        } catch (MalformedURLException e) {
  
          e.printStackTrace();
  
        } catch (IOException e) {
  
          e.printStackTrace();
  
        }
  </code></pre>