Arora
Arora

Reputation: 113

How to post raw json below in the body of retrofit request?

Here I am using retrofit 1.9 and I have to post this json in post request.

{
"note": "",
"amount": "0",
"frequency": null,
"patient": "[email protected]",
"doctor": "",
"date": "2016-04-27",
"reminder": 
[
{
    "days": [2],
    "time": "06:29:00"
}, 
{
    "days": [2, 3],
    "time": "06:30:00"
}
],
"salt": "Abobotulinum Toxin A Injection",
"method": 2,
"unit": 1
   } 

Thanks in advance.

Upvotes: 0

Views: 970

Answers (1)

Linh Nguyen
Linh Nguyen

Reputation: 1264

just create an Object like

public class PostObject{
        String note;
        String amount;
        String frequency;
        String patient;
        String doctor;
        String date;
        String salt;
        int method;
        int unit;
        List<Reminder> reminder;

        class Reminder{
            List<Integer> days;
            String time;
        }

    }

and set your request body object

Upvotes: 1

Related Questions