4

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?

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

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

#
1
  • you can also append a dummy formparam to "catch" the newline. – Cheeso Mar 19 '16 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.