Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mozilla rest client post json object

I am using Mozilla fire fox add-on RESTClient to test my web-services. Up to this I was using POST method by setting header Content-Type:application/x-www-form-urlencoded and data separated by & in request body e.g. id=1&title=abc

But now I want to POST the JSON object to using the same service. The sample objects are as below :

[
    {
         "id": 4
         "type":"alpha", 
         "title":"Title1"
    }
]

OR

[
    {
         "id": 4
         "type":"alpha", 
         "title":"Alpha"
    },
    {
         "id": 5
         "type":"beta", 
         "title":"Beta"
    },
    {
         "id": 6
         "type":"gama", 
         "title":"Gama"
    }
]

OR

[
    {
        "id": 5,
        "type":"beta", 
        "title":"Sample beta", 
        "children":[{
                "id": 6,
                "type":"betachild", 
                "title":"Beta child 1"
            },
            {
                "id": 7,
                "type":"betachild", 
                "title":"Beta child 2"
            },
            {
                "id": 8,
                "type":"betachild", 
                "title":"Beta child 3"
            }
        ]
    }
] 

OR

[
    {
        "id": 5,
        "type":"beta", 
        "title":"Sample beta", 
        "children":[{
                "id": 6,
                "type":"betachild", 
                "title":"Beta child 1"
            },
            {
                "id": 7,
                "type":"betachild", 
                "title":"Beta child 2"
            },
            {
                "id": 8,
                "type":"betachild", 
                "title":"Beta child 3"
            }
        ]
    }, 
    {
        "id": 9,
        "type":"beta", 
        "title":"Sample gama", 
        "children":[{
                "id": 10,
                "type":"gamachild", 
                "title":"Gama child 1"
            },
            {
                "id": 11,
                "type":"gamachild", 
                "title":"Gama child 2"
            },
            {
                "id": 12,
                "type":"gamachild", 
                "title":"Gama child 3"
            }
        ]
    }
] 

How can I pass such JSON object in POST request using RESTClient add-on?

like image 404
Dev Avatar asked May 11 '15 12:05

Dev


1 Answers

Set the content type as Content-type:application/json

like image 85
Ushani Avatar answered Oct 11 '22 13:10

Ushani