Mozilla rest client post json object

Dev picture Dev · May 11, 2015 · Viewed 9.1k times · Source

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?

Answer

Ushani picture Ushani · Aug 14, 2015

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