I'm creating an extension I don't know the reason for this error

the codes are these here

 @SimpleEvent(description = "Create a specific payment using your payment method id")
                    public void PREFERENCE_SPECIF(String URL, String response) {
                      
                      EventDispatcher.dispatchEvent(this, "PREFERENCE_SPECIF", URL);

                      URL url = new URL("https://api.mercadopago.com/checkout/preferences");
                      HttpURLConnection http = (HttpURLConnection)url.openConnection();
                      http.setRequestMethod("POST");
                      http.setDoOutput(true);
                      http.setRequestProperty("Authorization", "Bearer TEST-3310708299438226-092605-5ae9213774e815bb24c61d0a731d96ca-258257874");
                      http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

                      String data = "{teste}";

                      byte[] out = data.getBytes(StandardCharsets.UTF_8);

                    OutputStream stream = http.getOutputStream();
                    stream.write(out);

                    EventDispatcher.dispatchEvent(this,http.getResponseCode() + " " + http.getResponseMessage(),response);
                    http.disconnect();


                    }

somebody help me

You haven’t imported StandardCharsets.
So either import java.nio.charset.StandardCharsets or replace it with utf-8.

However, I am sure you are gonna ask few more questions because your code wouldn’t work at all.
So I suggest you to check Web component’s source before creating any network related extension.

2 Likes

also please follow the naming conventions…

Taifun

1 Like