I'm using retrofit as my network library, and I want to send a JSON array as x-www-form-urlencoded
, but I don't know how to do that.
Here is my request API :
@POST("book")
@FormUrlEncoded
Call<BookTicket> BookFlight(@Header("Authorization") String authorization,
@Header("Content-Type") String content_type,
@Field("rootType") Integer rootType ,
@Field("BookingStep2") ArrayList<JSONObject> BookingStep2
);
Here is a sample request :
{
"rootType": 1,
"BookingStep2": {
"OriginFlightSegment": {
"FlightNumber": "sample",
"Source": "sample",
"TotalTime": "sample",
"FareDatas": [
{
"PassengerType": 1,
"Endorsements": "sample",
"FareBasisCode": "sample"
},
{
"PassengerType": 1,
"Endorsements": "sample",
"FareBasisCode": "sample"
}
]
}
}
}
Is it right to send JSON array as field in retrofit?