gn-api-sdk-java-examples icon indicating copy to clipboard operation
gn-api-sdk-java-examples copied to clipboard

Erro ao gerar Charge

Open juliosilvacwb opened this issue 8 years ago • 2 comments

Quando eu tento gerar um charge com minhas credenciais utilizando a API no meu servidor tomcat 7, utilizando JAVA 7, recebo a seguinte exception, alguma orientação de como resolver?

java.lang.IllegalStateException: Already connected at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3071)

Meu código:

` try {

		/* Setando credenciais */
		JSONObject options = new JSONObject();
		options.put("client_id", "meu_id");
		options.put("client_secret", "meu_secret");
		options.put("sandbox", true);
   
   
		JSONArray items = new JSONArray();
   
		JSONObject item = new JSONObject();
		item.put("name", "Teste");
		item.put("amount", 1);
		item.put("value", 5000);
   
		items.put(item);
   		
		/* Definindo body da transação */
		JSONObject body = new JSONObject();
		body.put("items", items);
   	
		/* Requisitando transação, retorno setado em charge */
	    Gerencianet gn = new Gerencianet(options);
	    JSONObject responseCharge = gn.call("createCharge", new HashMap<String,String>(), body);
	    System.out.println(responseCharge);
	} catch(Exception e) {
		e.printStackTrace();
	}`

juliosilvacwb avatar Apr 13 '18 19:04 juliosilvacwb

Conseguiu resolver?

timoteo-jorge avatar Mar 14 '20 17:03 timoteo-jorge

Mesmo problema :/

Heitorallmeida avatar Dec 23 '21 16:12 Heitorallmeida