Not able to create customer using java language based sdk

language-based SDKs

got the below error message:
java.util.concurrent.CompletionException: java.lang.NoSuchMethodError: ‘okhttp3.RequestBody okhttp3.RequestBody.create(byte, okhttp3.MediaType)’

SquareClient badClient = new SquareClient.Builder()
.environment(Environment.SANDBOX)
.accessToken(“ACCESS_TOKEN”)
.build();
CustomersApi customersApi = badClient.getCustomersApi();
Address bodyAddress = new Address.Builder()
.addressLine1(“500 Electric Ave”)
.addressLine2(“Suite 600”)
.addressLine3(“address_line_38”)
.locality(“New York”)
.sublocality(“sublocality2”)
.administrativeDistrictLevel1(“NY”)
.postalCode(“10003”)
.country(“US”)
.build();
CreateCustomerRequest body = new CreateCustomerRequest.Builder()
.idempotencyKey(“idempotency_key1”)
.givenName(“Amelia”)
.familyName(“Earhart”)
.companyName(“company_name2”)
.nickname(“nickname2”)
.emailAddress(“[email protected]”)
.address(bodyAddress)
.phoneNumber(“1-212-555-4240”)
.referenceId(“YOUR_REFERENCE_ID”)
.note(“a customer”)
.build();

	customersApi.createCustomerAsync(body).thenAccept(result -> {
		System.out.println("=============" + result.toString());
	}).exceptionally(exception -> {
		exception.printStackTrace();
		return null;
	});

:wave: This is a method not found error. This happens when the SDK isn’t correctly configured to call the Customers API. :slightly_smiling_face:

Please let me know what are the configuration need to do. when i call location it works fine.

location [Location [id=L8J9QT38WP19D, name=epharmacy, address=Address [addressLine1=1600 Pennsylvania Ave NW, addressLine2=null, addressLine3=null, locality=Washington, sublocality=null, sublocality2=null, sublocality3=null, administrativeDistrictLevel1=DC, administrativeDistrictLevel2=null, administrativeDistrictLevel3=null, postalCode=20500, country=US, firstName=null, lastName=null, organization=null], timezone=UTC, capabilities=[CREDIT_CARD_PROCESSING, AUTOMATIC_TRANSFERS], status=ACTIVE, createdAt=2022-01-09T13:39:33.183Z, merchantId=ML488YBKMJ3W6, country=US, languageCode=en-US, currency=USD, phoneNumber=null, businessName=epharmacy, type=PHYSICAL, websiteUrl=null, businessHours=BusinessHours [periods=null], businessEmail=null, description=null, twitterUsername=null, instagramUsername=null, facebookUrl=null, coordinates=null, logoUrl=null, posBackgroundUrl=null, mcc=7299, fullFormatLogoUrl=null, taxIds=null]]

java.util.concurrent.CompletionException: java.lang.NoSuchMethodError: ‘okhttp3.RequestBody okhttp3.RequestBody.create(byte, okhttp3.MediaType)’
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1113)
at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2235)
at com.squareup.square.api.DefaultCustomersApi.lambda$createCustomerAsync$6(DefaultCustomersApi.java:232)
at com.squareup.square.api.BaseApi.makeHttpCallAsync(BaseApi.java:144)
at com.squareup.square.api.DefaultCustomersApi.createCustomerAsync(DefaultCustomersApi.java:230)

It got fixed after I changed the version in pom

Glad to hear you figured it out. What was the version you need to change in pom? :slightly_smiling_face: