'how to use retrofit @Post to send this body to restApi server in kotlin : [duplicate]
Solution 1:[1]
for sending nested json with retrofit , must use @Body annotation in api interface, for above JSON :
first make a data class for your hole JSON :
data class YourJSON (@SerializedName("data")
var data : String,
@SerializedName("data2")
var data2: Data2 ,
)
then make a data class for another object inside the JSON :
data class Data2 (@SerializedName("obj")
var obj: String,
@SerializedName("obj1")
var obj1: String ,
@SerializedName("obj2")
var obj2: String ,
@SerializedName("obj3")
var obj3: Int
)
then make an interface class :
interface ApiService {
@POST(/api/your/url)
fun sendData(
@Body yourJson : YourJSON,
): Observable <yourResponse> }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ali Salehi |

