114

I've installed Firefox RESTclient add-on but , I'm having hard time figuring out how to pass POST parameters. Is there a specific format to do this? Or is there any other tool which can be used to debug an REST API on Mac OS X ?

Rukshan
  • 7,902
  • 6
  • 43
  • 61

5 Answers5

213

If you want to submit a POST request

  1. You have to set the “request header” section of the Firefox plugin to have a “name” = “Content-Type” and “value” = “application/x-www-form-urlencoded
  2. Now, you are able to submit parameter like “name=mynamehere&title=TA” in the “request body” text area field
shA.t
  • 16,580
  • 5
  • 54
  • 111
Mahmoud Khaled
  • 6,226
  • 6
  • 37
  • 42
  • This gets you part of the way. If you're using the Parameters tab, you have to switch back to Content to Send and press the "Body from Parameters" button – Scott Arciszewski Nov 18 '14 at 21:15
  • jsut extending the answer.if you are sending the parameters then at your controller also you should mention consumes="application/x-www-form-urlencoded" in request mapping.hope this will give idea from the controller side aswell. – Mohan Jan 08 '15 at 09:42
47

Here is a step by step guide (I think this should come pre-loaded with the add-on):

  1. In the top menu of RESTClient -> Headers -> Custom Header
  2. In the pop-up box, enter Name: Content-Type and Value: application/x-www-form-urlencoded
  3. Check the "Save to favorite" box and click Okay.
    Now you will see a "Headers" section with your newly added data.
  4. Then in the Body section, you can enter your data to post like:

    username=test&name=Firstname+Lastname
    
  5. Whenever you want to make a post request, from the Headers main menu, select the Content-Type:application/x-www-form-urlencoded item that you added and it should work.

shA.t
  • 16,580
  • 5
  • 54
  • 111
happyhardik
  • 24,987
  • 7
  • 47
  • 60
11

You can send the parameters in the URL of the POST request itself.

Example URL:

localhost:8080/abc/getDetails?paramter1=value1&parameter2=value2

Once you copy such type of URL in Firefox REST client make a POST call to the server you want

shA.t
  • 16,580
  • 5
  • 54
  • 111
Heggi
  • 504
  • 4
  • 12
  • 2
    Doesn't work for me. Are you sure it'll work for a POST ? it seems this is a GET call. – Rukshan Oct 30 '12 at 05:10
  • 2
    Yes, it should work for a POST request. I have used it. You can make a POST call with such URLs. – Heggi Oct 30 '12 at 05:17
  • 1
    its not a POST, I have a wireshark record to show: POST /restService/usersPost/test?param1=hallo HTTP/1.1 Host: xxx.xxx.xxx.xxx:9090 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: null Accept-Encoding: gzip, deflate Content-Length: 0 Content-Type: text/plain; charset=UTF-8 Connection: keep-alive Pragma: no-cache Cache-Control: no-cache – beagle Oct 30 '13 at 12:18
  • We should not ssupply data in url when using post that is wrong way doing that. – Mohd Mufiz Nov 05 '14 at 08:41
  • it cannot be exposed the parameters in URL for post,it is not recommended. – Mohammed mansoor Aug 15 '16 at 08:24
  • I think this needs to be handled with something for example like `[FromUri]` in Asp.Net ;). – shA.t Nov 05 '17 at 13:43
5

Request header needs to be set as per below image.add request header

request body can be passed as json string in text area. enter image description here

Prashant Sharma
  • 375
  • 3
  • 5
2

I tried the methods mentioned in some other answers, but they look like workarounds to me. Using Firefox Add-on RESTclient to send HTTP POST requests with parameters is not straightforward in my opinion, at least for the version I'm currently using, 2.0.1.

Instead, try using other free open source tools, such as Apache JMeter. It is simple and straightforward (see the screenshot as below)

enter image description here

Yuci
  • 27,235
  • 10
  • 114
  • 113