Help Center/ Object Storage Service/ FAQs/ APIs and SDKs/ What Can I Do When Error Message "okhttp3.RequestBody.create(java.lang.String,okhttp3.MediaType)" Is Displayed for Java SDK?
Updated on 2022-09-27 GMT+08:00

What Can I Do When Error Message "okhttp3.RequestBody.create(java.lang.String,okhttp3.MediaType)" Is Displayed for Java SDK?

Symptom

Error message "okhttp3.RequestBody.create(java.lang.String,okhttp3.MediaType)" is reported for Java SDK.

Cause

Spring Boot specifies the version of third-party dependencies. For details, see Spring Boot Managed Dependency Coordinates. When the OBS SDK is introduced to a Spring Boot framework, the version of OkHttp3 (dependency specified by the SDK) will be changed from 4.8.0 to 3.14.9. As a result, the specified method cannot be obtained. To avoid this issue, you can use the bundle SDK that integrates third-party dependencies, or explicitly reference OkHttp3 4.8.0 in your project.

Solution

Use the following code to import the bundle SDK to replace the original one.

<dependency>
    <groupId>com.huaweicloud</groupId>
    <artifactId>esdk-obs-java-bundle</artifactId>
    <version>[3.21.8,)</version>
</dependency>