question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(byte[], okhttp3.MediaType)'

See original GitHub issue

Hello,

after upgrading to the version 1.25.0 (from 1.24.0) i get the error in the title when getting TokenHolder.

My code looks the same as in your docs:

AuthAPI authAPI = new AuthAPI("{YOUR_DOMAIN}", "{YOUR_CLIENT_ID}", "{YOUR_CLIENT_SECRET}");
AuthRequest authRequest = authAPI.requestToken("https://{YOUR_DOMAIN}/api/v2/");
TokenHolder holder = authRequest.execute();
ManagementAPI mgmt = new ManagementAPI("{YOUR_DOMAIN}", holder.getAccessToken());

The problem is this line: TokenHolder holder = authRequest.execute();

In previous versions everything worked great but since update to 1.25.0 it throws the following error:

Caused by: java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(byte[], okhttp3.MediaType)'
        at com.auth0.net.CustomRequest.createRequestBody(CustomRequest.java:50)
        at com.auth0.net.ExtendedBaseRequest.createRequest(ExtendedBaseRequest.java:49)
        at com.auth0.net.BaseRequest.execute(BaseRequest.java:29)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:29 (14 by maintainers)

github_iconTop GitHub Comments

7reactions
jsalinaspolocommented, Dec 2, 2020

It could be fixed by adding strictly version into the dependencies

    implementation("com.squareup.okhttp3:okhttp") {
        version {
            strictly '4.9.0'
        }
    }

Or adding the BOM into the dependencyManagement

dependencyManagement {
    imports {
        mavenBom "com.squareup.okhttp3:okhttp-bom:4.9.0"
    }
}
5reactions
MarcusBielcommented, Dec 28, 2020

Having the same issue… please fix asap!

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - RequestBody.create(contentType, content) Deprecated
toMediaTypeOrNull() . For example how we need to create request body now since okhttp:4.1.0 import okhttp3.MediaType.Companion.
Read more >
Ringout example throws exception java.lang ...
It seems that this error is related to function okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType) , but I am ...
Read more >
java.lang.NoSuchMethodError: okhttp3.RequestBody.create ...
http3 version that i use is 4.9.2(it in pom) java version - 8 binance-connector-java - 1.2 public String orderCreate(String currency, ...
Read more >
Java - CSDN博客
RequestBody.create(Ljava/lang/String;Lokhttp3/MediaType;)Lokhttp3/RequestBody; 以上是某位大佬说的未解决我的问题说是web3j 版本的问题某个入口服务 ...
Read more >
Developers - NoSuchMethodError: 'okhttp3.RequestBody ...
NoSuchMethodError : 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found