Skip to content

Instantly share code, notes, and snippets.

@shihabmi7
Created August 12, 2020 07:10
Show Gist options
  • Save shihabmi7/899cb63b6a4fafb644de33eef2be4c0d to your computer and use it in GitHub Desktop.
Save shihabmi7/899cb63b6a4fafb644de33eef2be4c0d to your computer and use it in GitHub Desktop.
Sent Plain JSON as String with Moshi & Retrofit
want to sent plain json as post request, with retrofit and moshi converter ???
{"id":1,"firstName":"Lokesh","lastName":"Gupta","roles":["ADMIN","MANAGER"]}
Retrofit.Builder()
.client(client)
.baseUrl(baseUrl)
.addConverterFactory(ScalarsConverterFactory.create()) // you need to add this for sending plain json object
.addConverterFactory(MoshiConverterFactory.create(moshi))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment