Skip to content

Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false') #816

Open
@mehaksaini2811

Description

@mehaksaini2811

Issue Summary

I'm using the code from here to create a custom twilio rest client. Locally it works fine but if I try to connect from my organization's dev server using proxy it throws the error Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

Steps to Reproduce

  1. This is the first step
  2. This is the second step
  3. Further steps, etc.

Code Snippet

// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
import io.github.cdimascio.dotenv.Dotenv;

public class Example {

  public static void main(String args[]) {
    Dotenv dotenv = Dotenv.configure().directory(".").load();
    String ACCOUNT_SID = dotenv.get("ACCOUNT_SID");
    String AUTH_TOKEN = dotenv.get("AUTH_TOKEN");
    String PROXY_HOST = dotenv.get("PROXY_HOST");
    int PROXY_PORT = Integer.parseInt(dotenv.get("PROXY_PORT"));

    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ProxiedTwilioClientCreator clientCreator = new ProxiedTwilioClientCreator(
      ACCOUNT_SID,
      AUTH_TOKEN,
      PROXY_HOST,
      PROXY_PORT
    );
    TwilioRestClient twilioRestClient = clientCreator.getClient();
    Twilio.setRestClient(twilioRestClient);

    VerificationCreator verificationCreator = Verification.creator(verifySid, phoneNumber, deliveryChannel);
     verificationCreator.setCustomCode(code);

    System.out.println(message.getSid());
  }
}

Exception/Log

Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false'). I

If I remove the proxy I get a different error saying

No content to map due to end-of-input
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1]

Technical details:

  • twilio-java version: 10.4.1
  • java version: 21

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: highNeeds immediate attention; blockers or critical

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions