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.

Unable to create @Body

See original GitHub issue

Hello, I try to use Moshi with Retrofit, I used Yelp to generate calls and objects (https://github.com/Yelp/swagger-gradle-codegen)

I receive an error : Unable to create @Body converter for class ObjectRequest (parameter #1)

@POST("/xxxxxxx")
fun call(@Body object: ObjectRequest): Single<ObjectResponse>
class ObjectRequest {
    @Json(name = "field")
    var field: String? = null
}
Retrofit.Builder()
            .baseUrl("xxxxxxxxxxxxxx")
            .addConverterFactory(MoshiConverterFactory.create())
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .client(okHttpClient)
            .build()
            .create(xxxxxx::class.java)
    val moshi = Moshi.Builder()
            .add(XNullableAdapterFactory())
            .add(KotlinJsonAdapterFactory())
            .add(TypesAdapterFactory())
            .build()

Retrofit.Builder()
            .baseUrl("xxxxxxxxxxxxxx")
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .client(okHttpClient)
            .build()
            .create(xxxxxx::class.java)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
JakeWhartoncommented, Jul 10, 2019

Yes. Moshi does not serialize platform types by default. Change it to the interface List or register an adapter for ArrayList with Moshi.

0reactions
zelyoncommented, Jul 10, 2019

My bad, i have auto-formatted some classes with ArrayList instead of List, it works

Read more comments on GitHub >

github_iconTop Results From Across the Web

NX10 Unable to create body - Siemens: UG/NX - Eng-Tips
Trying to create a keyway using sketch 5 but whenever I select the face it says Unable to create body - change the...
Read more >
Flat pattern, unable to create body - Siemens Communities
DaveK asked a question. I hate when it gives you the preview of exactly what you want, and then says "Unable to create...
Read more >
Retrofit: Unable to create @Body converter for class
Solution: declare body value in your interface with next: @Body RequestBody body and wrap String JSON object:.
Read more >
Unable to create a Flat Pattern of sheet metal body in Fusion ...
Unable to create a Flat Pattern of a sheet metal bend body in Fusion 360. Causes: The design has flanges that are overlapping...
Read more >
Unable to create single body that is the sum of the input bodies!
25 votes, 16 comments. 51K subscribers in the SolidWorks community. ALL posts related to SOLIDWORKS are welcome. Share what you know.
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