5

When I use restclient with Content-Type: application/x-www-form-urlencoded, restclient sends newlines with the data.

For example:

POST :domain/thing
Content-Type: application/x-www-form-urlencoded
data=foobar

The endpoint receives a form with the value 'data': 'foobar\n'.

I could modify require-final-newline such that the last query in the file would work properly, but since requests are separated by comment lines, I still get the extra newlines for all preceding requests.

How can I get restclient to pass the forms correctly?

Matthew Piziak
  • 5,958
  • 3
  • 29
  • 77
  • interesting because talking about Restful API over HTTP, the most popular content-types I met are application/xml & application/json. Browsing the [examples](https://raw.githubusercontent.com/pashky/restclient.el/master/examples/httpbin) I did not see anything related to application/x-www-form-urlencoded :( – Nsukami _ Dec 24 '14 at 02:25
  • 1
    This is being investiguated at https://github.com/pashky/restclient.el/issues/71 – Silex Mar 24 '15 at 13:39

1 Answers1

5

In the current version, if you make sure that each of your requests has a comment line immediately succeeding it, then the forms will be passed correctly.

For example, the following code will send 'data':'foobar', with no extra newline. The content length received by netcat is exactly 11, which was what we wanted.

POST :domain/thing
Content-Type: application/x-www-form-urlencoded
data=foobar
#

The block below, on the other hand, returns 'data': 'foobar\n' with a content length of 12.

POST :domain/thing
Content-Type: application/x-www-form-urlencoded
data=foobar

#
Matthew Piziak
  • 5,958
  • 3
  • 29
  • 77