Git Product home page Git Product logo

restclient.el's Introduction

restclient.el

This is a tool to manually explore and test HTTP REST webservices. Runs queries from a plain-text query sheet, displays results as a pretty-printed XML, JSON and even images.

Usage

You can easily install restclient using package.el from MELPA.

Alternatively, deploy restclient.el into your site-lisp as usual, then add (require 'restclient) to your Emacs start-up file.

Once installed, you can prepare a text file with queries.

restclient-mode is a major mode which does a bit of highlighting and supports a few additional keypresses:

  • C-c C-c: runs the query under the cursor, tries to pretty-print the response (if possible)
  • C-c C-r: same, but doesn't do anything with the response, just shows the buffer
  • C-c C-v: same as C-c C-c, but doesn't switch focus to other window
  • C-c C-b: same as C-c C-c, but doesn't show response buffer
  • C-c C-p: jump to the previous query
  • C-c C-n: jump to the next query
  • C-c C-.: mark the query under the cursor
  • C-c C-u: copy query under the cursor as a curl command
  • C-c C-g: start a helm session with sources for variables and requests (if helm is available, of course)
  • C-c n n: narrow to region of current request (including headers)
  • TAB: hide/show current request body, only if
  • C-c C-a: show all collapsed regions
  • C-c C-i: show information on restclient variables at point

The last two functions are implemented as restclient-outline-mode minor mode, which is activated by default via hook for major mode. Remove this hook using (remove-hook 'restclient-mode-hook 'restclient-outline-mode) if you don't wish to have this behaviour, or it clashes with any other binding for TAB like autocomplete.

Query file example:

# -*- restclient -*-
#
# Gets  all Github APIs, formats JSON, shows response status and headers underneath.
# Also sends a User-Agent header, because the Github API requires this.
#
GET https://api.github.com
User-Agent: Emacs Restclient

#
# XML is supported - highlight, pretty-print
#
GET http://www.redmine.org/issues.xml?limit=10

#
# It can even show an image!
#
GET http://upload.wikimedia.org/wikipedia/commons/6/63/Wikipedia-logo.png
#
# A bit of json GET, you can pass headers too
#
GET http://jira.atlassian.com/rest/api/latest/issue/JRA-9
User-Agent: Emacs24
Accept-Encoding: compress, gzip

#
# Post works too, entity just goes after an empty line. Same is for PUT.
#
POST https://jira.atlassian.com/rest/api/2/search
Content-Type: application/json

{
        "jql": "project = HCPUB",
        "startAt": 0,
        "maxResults": 15,
        "fields": [
                "summary",
                "status",
                "assignee"
        ]
}
#
# And delete, will return not-found error...
#
DELETE https://jira.atlassian.com/rest/api/2/version/20

# Set a variable to the value of your ip address using a jq expression
GET http://httpbin.org/ip
-> jq-set-var :my-ip .origin

Lines starting with # are considered comments AND also act as separators.

HTTPS and image display requires additional dll's on windows (libtls, libpng, libjpeg etc), which are not in the emacs distribution.

More examples can be found in the examples directory.

In-buffer variables

You declare a variable like this:

:myvar = the value

or like this:

:myvar := (some (artbitrary 'elisp)

In second form, the value of variable is evaluated as Emacs Lisp form immediately. Evaluation of variables is done from top to bottom. Only one one-line form for each variable is allowed, so use (progn ...) and some virtual line wrap mode if you need more. There's no way to reference earlier declared restclient variables, but you can always use setq to save state.

Variables can be multiline too:

:myvar = <<
Authorization: :my-auth
Content-Type: application/json
User-Agent: SomeApp/1.0
#

or

:myvar := <<
(some-long-elisp
    (code spanning many lines)
#

<< is used to mark a start of multiline value, the actual value is starting on the next line then. The end of such variable value is the same comment marker # and last end of line doesn't count, same is for request bodies.

After the var is declared, you can use it in the URL, the header values and the body.

# Some generic vars

:my-auth = 319854857345898457457
:my-headers = <<
Authorization: :my-auth
Content-Type: application/json
User-Agent: SomeApp/1.0
#

# Update a user's name

:user-id = 7
:the-name := (format "%s %s %d" 'Neo (md5 "The Chosen") (+ 100 1))

PUT http://localhost:4000/users/:user-id/
:my-headers

{ "name": ":the-name" }

Varaibles can also be set based on the body of a response using the per-request hooks

# set a variable :my-ip to the value of your ip address using elisp evaluated in the result buffer
GET http://httpbin.org/ip
-> run-hook (restclient-set-var ":my-ip" (cdr (assq 'origin (json-read))))

# same thing with jq if it's installed
GET http://httpbin.org/ip 
-> jq-set-var :my-ip .origin

# set a variable :my-var using a more complex jq expression (requires jq-mode)
GET https://httpbin.org/json
-> jq-set-var :my-var .slideshow.slides[0].title

# hooks come before the body on POST
POST http://httpbin.org/post
-> jq-set-var :test .json.test

{"test": "foo"}

File uploads

Restclient now allows to specify file path to use as a body, like this:

POST http://httpbin.org/post
Content-type: text/plain

< /etc/passwd

Caveats:

  • Multiline variables can be used in headers or body. In URL too, but it doesn't make sense unless it was long elisp expression evaluating to simple value.
  • Yet same variable cannot contain both headers and body, it must be split into two and separated by empty line as usual.
  • Variables now can reference each other, substitution happens in several passes and stops when there's no more variables. Please avoid circular references. There's customizable safeguard of maximum 10 passes to prevent hanging in this case, but it will slow things down.
  • Variable declaration only considered above request line.
  • Be careful of what you put in that elisp. No security checks are done, so it can format your hardrive. If there's a parsing or evaluation error, it will tell you in the minibuffer.
  • Elisp variables can evaluate to values containing other variable references, this will be substituted too. But you cannot substitute parts of elisp expressions.

Customization

There are several variables available to customize restclient to your liking. Also, all font lock faces are now customizable in restclient-faces group too.

restclient-log-request

Default: t

Determines whether restclient logs to the *Messages* buffer.

If non-nil, restclient requests will be logged. If nil, they will not be.

restclient-same-buffer-response

Default: t

Re-use same buffer for responses or create a new one each time.

If non-nil, re-use the buffer named by rest-client-buffer-response-name for all requests.

If nil, generate a buffer name based on the request type and url, and increment it for subsequent requests.

For example, GET http://example.org would produce the following buffer names on 3 subsequent calls:

  • *HTTP GET http://example.org*
  • *HTTP GET http://example.org*<2>
  • *HTTP GET http://example.org*<3>

restclient-same-buffer-response-name

Default: *HTTP Response*

Name for response buffer to be used when restclient-same-buffer-response is true.

restclient-inhibit-cookies

Default: nil

Inhibit restclient from sending cookies implicitly.

restclient-response-size-threshold

Default: 100000

Size of the response buffer restclient can display without huge performance dropdown. If response buffer will be more than that, only bare major mode will be used to display it. Set to nil to disable threshold completely.

Known issues

  • Comment lines # act as end of entity. Yes, that means you can't post shell script or anything with hashes as PUT/POST entity. I'm fine with this right now, but may use more unique separator in future.
  • I'm not sure if it handles different encodings, I suspect it won't play well with anything non-ascii. I'm yet to figure it out.
  • Variable usages are not highlighted
  • If your Emacs is older than 26.1, some GET requests to localhost might fail because of that bug in Emacs/url.el. As a workaround you can use 127.0.0.1 instead of localhost.

History

  • 01/Aug/2016 Added ability to narrow to region
  • 06/Apr/2016 Helm sources for variables and requests added.
  • 06/Apr/2016 File uploads! See upstairs for syntax.
  • 06/Apr/2016 Added customizable faces for all syntax highlighting, so it can be used in themes.
  • 05/Apr/2016 Added ability to declare multi-line variables (e.g. set of headers repeated for each request) and substitute variable values recursively.
  • 25/Mar/2015 Chop last newline from request body. If you really need to send one, just add one more, otherwise url-encoded POSTs will fail.
  • 15/Jun/2013 Added support for variables.

Related 3rd party packages

  • company-restclient: It provides auto-completion for HTTP methods and headers in restclient-mode. Completion source is given by know-your-http-well.
  • ob-restclient: An extension to restclient.el for emacs that provides org-babel support.
  • restclient.vim: Brings the restclient to vim! Responses display in vim's internal pager.

License

Public domain, do whatever you want.

Author

Pavel Kurnosov [email protected]

restclient.el's People

Contributors

agspathis avatar alexey-martynov avatar bosko avatar bounceme avatar chessman avatar dassburger avatar dbarros avatar dochang avatar felipeochoa avatar fesiqueira avatar glucas avatar gvalkov avatar iamjarvo avatar kungi avatar leppert avatar markus1189 avatar mnemonikk avatar nitishch avatar pashky avatar phongphan avatar purcell avatar salewski avatar scottdw avatar spacebat avatar syohex avatar tarsius avatar vetler avatar wi11dey avatar x12a1f avatar yamad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

restclient.el's Issues

peculiar error on POST with no description

I'm trying to test a github webhook on a local server that I have set up in lieu of making it reachable from outside. I have the payload and header info, so I tested it in my scratch buffer with no success and a weird error.

Log:

Contacting host: 192.168.1.6:8080
error in process sentinel: peculiar error [2 times]
POST http://192.168.1.6:8080/api/hook/github.com/[TOKEN_REMOVED]
Content-Type: application/x-www-form-urlencoded

{
  "action": "opened",
  "number": 220,
  "pull_request": {
...

A GET to the root URL works, so I know the server is working. Is it possible to get more info from this side?

"Malformed HTTP message" every other request

Every other request, my server says

[I 141118 13:13:42 http1connection:249] Malformed HTTP message from 127.0.0.1: Malformed HTTP headers: '\r\nGET /translate?langpair=nno%7Cnob&q=hei HTTP/1.1\r\nMIME-Version: 1.0\r\nConnection: keep-alive\r\nExten'

so it seems like some variable is not being emptied or buffer not being flushed.

Allow the use of elisp expressions to calculate HTTP messages

On one rest system I'm developing I have to include an HMAC string in each request. This string is calculated using a secret key and the contents of the HTTP message. To use restclient.el it would be really useful if I could elisp to calculate that string for me. The alternative is that I do it by hand, and that's pretty tedious.

Conceptually what I want is something like this

POST http://127.0.0.1:58681/endpoint
Content-Type: application/json
X-Ycm-Hmac: (base64-encode-string (encode-hex-string (ycmd--hmac-function {{msg-contents}} ycmd--hmac-secret)))

{some: json}

I don't know how common this use-case is, but it's almost a show-stopper in some situations.

Whitespace handling in HTTP in entities

I noticed that the rest client attaches some extra whitespace in the HTTP entity it sends, regardless of what method is being used in the request. In my case, when working with a particularly strict server, I can't test GET or HEAD requests as they are not supposed to have any body; we could argue that that is not necessarily true in the HTTP specification, but in some cases it is just good to have more control on this aspect.

I also found this PR which looked abandoned and can't easily be merged as far as I can tell: #22

If I issue a new PR to trim the HTTP entity before sending the request will it be merged?

Re-use displayed *HTTP response* window

I get a new split window each time restclient-http-send-current is run. For example, the first time it is run, there are two windows, the REST buffer, and the reponse window. The second time it is run, the frame gets split again, with the REST buffer, a new response window, and some other buffer. It would be great if the HTTP response window was refreshed if it already displayed, without the frame being split again.

Doesn't do anything in Aquamacs

I successfully installed it in Aquamacs, and I have the REST Client mode available (syntax highlighting too). When trying the example in the README, nothing happens when I press C-c C-c (or C-c C-r). The only thing it does is to move the cursor to the top-left corner.

Wrong type argument: string, nil

Hello,
Latest update of restclient.el doesn't work for me anymore, whenever I try to C-c I get "Wrong type argument: string, nil". It works again if I revert to 20130227.1916 (in Melpa notation). Any idea on how to fix it?
Cheers,
Julien.

302 redirects

Hi Pasky, love restclient!

Firstly, does restclient handle 302s? I am testing some URL that requires me to login and do a POST but no response whatever. I then perform a separate GET request after the POST login attempt and it shows content for the logined user. Is this the way restclient works? I ask because I am accustomed to how other clients like the Postman works to follow the redirects.

Secondly, I thought it would be good to advertise on the 'frontpage' that we could inhibit restclient from sending cookies implicitly or rather specify explicitly the cookie settings we want. I found out about this only after some searching on the issues list:

# need to firstly turn on [Inhibit restclient from sending cookies implicitly] via M-x customize-variable

GET http://someserver.com
Cookie: SESSToken=SESSValue; otherCookieSetting=otherCookieValue

JSON strings with quoted characters are not displayed correctly

When the server returns something like

{ "msg": "Hello \"this\" is a test" }

It is shown in the emacs HTTP Response window as following:

{
  "msg": "Hello "this" is a test"
}

(note the missing backslashes)

Unfortunately I do not know enough lisp to fix it.

Entities with UTF-8 chars sometimes fail strangely

I am having a bad time figuring out why and what this is, but here is the simplest reproducible case I can come up with:

OK:

PUT http://httpbin.org/put
Content-Type: application/json

{
    "text": "João"
}

This will return the httpbin-formatted JSON response that includes this:

{
  ...
  "json": {
    "text": "Jo\u00e3o"
  }, 
  ...
}

However, if you use a payload with a second UTF-8 character, such as this:

PUT http://httpbin.org/put
Content-Type: application/json

{
    "text": "João Sá"
}

The httpbin response will include this instead:

{
  ...
  "json": null,
  ...
}

Testing this same experiment with curl does not reproduce the problem (the JSON is successfully parsed and shows up as expected in the httpbin response):

$ curl -X PUT http://httpbin.org/put -H "Content-Type: application/json" -d '{"text": "João Sá"}'
{
  ...
  "json": {
    "text": "Jo\u00e3o S\u00e1"
  }, 
  ...
}

non-json POST

Hello,

Is it possible to do non-json POST?

Here's what I tried:

POST http://someurl

field=test&field2=test2

Use restclient behind proxy

Hi

From my point of view, it looks like restclient does not follow the proxy settings set as environment variables. Inside a proxyfied emacs (ie, I can access to MELPA/marmelade/eww), restclient does not proxyfied the requests it makes.

I, for example, get this error when trying a simple POST

HTTP/1.0 500 Internal Server Error
Date: Thu, 22 Jan 2015 16:32:34 GMT
Server: Apache/2.4.6 (Ubuntu)
Content-Length: 21
Content-Type: text/plain
X-Cache: MISS from cacheserv.proxy.fr
Via: 1.1 cacheserv.proxy.fr:3128 (squid/2.7.STABLE5-20081030)
Connection: close

Internal Server Error

Let me know if you need more informations

restclient-jump-next not working

The command restclient-jump-next (bound to C-c C-n) does not move point. The corresponding command restclient-jump-prev (bound to C-c C-p) works as expected in the same buffer.

Testing with Emacs 24.4 -Q on Windows 8.1, with restclient 20150818.807. (Also tried on a recent Emacs 25 snapshot.)
.

A suggestion about documentation

Please consider moving the following line before the example code (currently it's right after the example) since using "#" is important for separating multiple requests:

"Lines starting with # are considered comments AND also act as separators."

This may benefit those who are too impatient to read the whole document (for example: me) :).

Just get another thought while writing this, is it possible to use the request method name as the boundary of requests: it's just a limited set of all capital words, at the start of line.

And, thanks. It's a great mode! Saved me some "man curl" already.

POST

See theme on stackoverflow about parameters for POST requests. Or --data option for curl.

So how can I use it in restclient.el? Is it implemented?

_UPD:_ Oh, I see: Content-Type: application/x-www-form-urlencoded required as well!
Thank you a lot! 😼

Failed to parse JSON string in which 4 numbers follow a unicode character

If an API returns a response containing a string, in which a 4 numbers follow a unicode character, such like "題1000" ("\u984c1000"), restclient failed to parse the response with C-c C-c.

Steps to reproduce

  1. Upload a file of which content is

    "\u984c1000"
    

    to any public site.

  2. Create a file as below and press C-c C-c on the line.

    GET <URL of the uploaded file>
    

Hang on Windows

I'm using restclient to interact with a locally-deployed web service. When I try to send a POST, my server receives/processes the request but my Emacs instance is left hanging with 'Contacting host: localhost:8180' in the mode line. At that point I have to kill the emacs process.

I'm using HTTP so there's no certs etc. involved. GET/DELETE seems to work fine. Has anyone else had this kind of problem? Any suggestions for debugging further - even just to have it time out so I don't have to kill emacs would be a big improvement. I can kill the web server and Emacs remains hung.

(Emacs 24.4, Windows 8)

ELPA package

Please add it to ELPA so it would be easier to install and update.

Perculiar error when GETing localhost:3000

Firstly, thanks for creating this useful mode for emacs :)
Regarding the error, I have the error below when I tried to do the get request to http://localhost:3000

error in process sentinel: peculiar error: "failed with code 111                                                                       
", :host, "localhost", :service, 3000

POST to https endpoint fails?

Hello, I am trying to POST JSON to an API I'm writing. Making curl requests works fine but I'm getting these errors from restclient.el

Request

POST https://www.example.com/
Content-Type: application/json

{
  "email": "[email protected]",
  "password": "secretP@55word"
}

Messages buffer output

Contacting host: **API URL**:443
Opening TLS connection to `**API URL**'...
Opening TLS connection with `gnutls-cli --insecure -p 443 **API URL**'...failed
Opening TLS connection with `gnutls-cli --insecure -p 443 **API URL** --protocols ssl3'...failed
Opening TLS connection with `openssl s_client -connect **API URL**:443 -no_ssl2 -ign_eof'...failed
Opening TLS connection to `**API URL**'...failed
url-http: Could not create connection to **API URL**:443

gnutls-cli version

$ /usr/local/bin/gnutls-cli --version
gnutls-cli 3.3.9

Create tag to get on melpa-stable

Hi, I'm trying to get from melpa to melpa-stable. Unfortunately, since restclient has no tags (git tag), it's not available there yet.

Basic access authentication for requests

Hi, and thanks for this nice Emacs extension!

I would just like to let you know that I would have liked to see restclient.el support for handling authentication for requests in the form of http://[email protected]/. No password would necessary for me, but that would of course be nice to have too. :-)

Thanks for whatever you can do!

In-buffer variables

Hello!

Thanks for createing restclient.el, I find it absolutely excellent. I love the simplicity, and I can't think of a better API for exploring services.

Here's an idea: What if I could declare some variables (like maybe some ID, or Cookies), and then it would be interpolated into the request before calling?

Something like this:

:event-id = 83641034
:missive-id = 343

# Get sent-status for an event and a missive
GET http://localhost:4005/events/:event-id/missives/sent-status/:missive-id

I would be happy to give it a go, if you would accept a pull request for something like this. :)

change tab indentation

I've got emacs generally indenting code the way I like. With spaces instead of tabs, 2 spaces of indentation.

however REST Client mode stubbornly inserts a TAB when I press TAB. Any idea how I can change that?

None of this from my .emacs has any effect:

(setq tab-width 2)
(setq js-indent-level 2)
(setq standard-indent 2)

(defvaralias 'c-basic-offset 'tab-width)
(defvaralias 'cperl-indent-level 'tab-width)

(setq-default indent-tabs-mode nil)

Backslashes in interpolated content cause problems

Thanks for writing restclient, it's very useful. I'm having a problem, though. Consider the following restclient section:

:foo = foo\bar
POST http://localhost/

:foo

This causes an (error "Invalid use of '\\' in replacement text") to be thrown from the restclient-replace-all-in-string function when it calls replace-regexp-in-string.

I imagine you probably want to pass t as the LITERAL argument to replace-regexp-in-string at that point. Either that, or document that backslashes in interpolated text need to be doubled up. (Personally, I'd prefer the former.)

Accept and Accept-Charset headers are not overwritten

When using the following in emacs:

#
GET http://localhost:8083/test/1
Accept: text/xml
Accept-Charset: utf-8

emacs actually sends

GET /test/1 HTTP/1.1
MIME-Version: 1.0
Connection: keep-alive
Extension: Security/Digest Security/SSL
Host: localhost:8083
Accept-charset: utf-8;q=1, gb2312;q=0.5, iso-8859-1;q=0.5, big5;q=0.5, iso-2022-jp;q=0.5, shift_jis;q=0.5, euc-tw;q=0.5, euc-jp;q=0.5, euc-jis-2004;q=0.5, euc-kr;q=0.5, us ascii;q=0.5, utf-7;q=0.5, hz-gb-2312;q=0.5, big5-hkscs;q=0.5, gbk;q=0.5, gb18030;q=0.5, iso-8859-5;q=0.5, koi8-r;q=0.5, koi8-u;q=0.5, cp866;q=0.5, koi8-t;q=0.5, windows-1251;q=0.5, cp855;q=0.5, iso-8859-2;q=0.5, iso-8859-3;q=0.5, iso-8859-4;q=0.5, iso-8859-9;q=0.5, iso-8859-10;q=0.5, iso-8859-13;q=0.5, iso-8859-14;q=0.5, iso-8859-15;q=0.5, windows-1250;q=0.5, windows-1252;q=0.5, windows-1254;q=0.5, windows-1257;q=0.5, cp850;q=0.5, cp852;q=0.5, cp857;q=0.5, cp858;q=0.5, cp860;q=0.5, cp861;q=0.5, cp863;q=0.5, cp865;q=0.5, cp437;q=0.5, next;q=0.5, hp-roman8;q=0.5, adobe-standard-encoding;q=0.5, iso-8859-16;q=0.5, iso-8859-7;q=0.5, windows-1253;q=0.5, cp737;q=0.5, cp851;q=0.5, cp869;q=0.5, iso-8859-8;q=0.5, windows-1255;q=0.5, cp862;q=0.5, iso-2022-jp-2004;q=0.5, cp874;q=0.5, iso-8859-11;q=0.5, viscii;q=0.5, windows-1258;q=0.5, iso-8859-6;q=0.5, windows-1256;q=0.5, iso-2022-cn;q=0.5, iso-2022-cn-ext;q=0.5, iso-2022-jp-2;q=0.5, iso-2022-kr;q=0.5, utf-16le;q=0.5, utf-16be;q=0.5, utf-16;q=0.5, x-ctext;q=0.5
Accept: */*
User-Agent: URL/Emacs (x86_64-pc-linux-gnu; X11)
Accept-Charset: utf-8
Accept: text/xml
Content-length: 0

(two Accept headers and two Accept-Charset headers)

Theme?

What is the color theme that you're using for restclient.el?

Automatically encode HTTP form variables

It would be cool if when we write this:

GET http://localhost/test
a=value
b=space value

it is translated into a request like this:

GET /test?a=value&b=space+value HTTP/1.1

and if you specify POST:

POST http://localhost/test
a=value
b=space value

the request would is encoded correctly:

POST /test HTTP/1.1
Content-Type: application/x-www-form-urlencoded

a=value&b=space+value

Basic Authorization: changes in authorization string are ignored

Hi!

I am using requests like:

:myparam = 0412345600

:xmltype = application/xml
:authstring1 = YmVfcmVzdF9hZG1pbkB2cfoo
:authstring2 = YmVfcmVzdF9hZG1pbkB2cbar


GET http://example.com/api/rest/service?serviceKey=:myparam
Authorization: Basic :authstring1
Accept-Encoding: :xmltype
Content-Type: :xmltype

This works.

However, when I change from authstring1 to authstring2, restclient.el still uses authstring1. Switching mode to nXML and back to restclient-mode did not help either. Same goes for closing the rest-request.xml-file and re-open it. I had to exit and re-start Emacs in order to make it work.

Please help me with a workaround and/or fix the issue.

Workaround: what do I have to do (clear variable, reset mode, ...) in order to switch authstring without having to exit/re-start Emacs?

Thanks!

Wrong fontification.

#
# - donation values
#
POST :base_url/data/donations.php?some_id=:some_id
[
    {
        "donation_id": "57",
        "text_id": "131",
        "user_id": "0",
        "details": "Barclays Bank\n\nAccount Number: 123456789\n\nSort Code: 20-52-00\n\nTransfer now!\n\nExtra text added here to check if line moves further down.\n\nExtra text added here to check if line moves further down.\n\nExtra text added here to check if line moves further down.",
        "text1": "https:\/\/www.somesstring",
        "text2": "Message.",
        "text3": "Another text"
    }
]

Screenshot

Org-mode integration

Hi!

This is a feature request:

Have you ever considered to create the glue that it is possible to integrate restclient.el into Org-mode?

It would be pretty cool to C-c C-c on following line ...

#+BEGIN_SRC REST
GET http://myserver/rest/dothis
Authorization: Basic YmVfcmVzdF9hZG1
Accept-Encoding: application/xml
#+END_SRC

... and get the XML response like this:

#+RESULTS:
: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
: <faultInfo xmlns="http://example.com/product/model">
:   <...>
: </faultInfo>

I am no ELISP programmer but I guess this feature is not much of a work for someone who is also familiar with Org-mode ...

POST hangs when a 201 Created is returned

restclient is the ultimate way of exploring REST APIs. I love it. I ran into a small problem and don't want to have to go to another tool even for a little bit.

I tried to pick up edebug to debug the problem but it was taking me too long. May revisit when I get a chance.

I'm exploring the creation of a resource via a REST API. When the API creates a resource, you get a 201 status code and the location of the new resource in a response header.

Here are the contents of my HTTP Response Buffer:

HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location
Date: Fri, 20 Mar 2015 21:31:15 GMT
Location: http://host/workflow/9035bfbd-e32e-1322-acd2-823c257ab1f1
Server: Apache-Coyote/1.1
Content-Length: 0
Connection: keep-alive

Here are the contents of my URL-DEBUG buffer:

http -> Found existing connection: host:80 #
http -> Reusing existing connection: host:80
http -> Marking connection as busy: host:80 #
http -> Request is:
POST /workflow HTTP/1.1
MIME-Version: 1.0
Connection: keep-alive
Extension: Security/Digest Security/SSL
Host: host
Accept: /
Content-Type: application/json
Content-length: 414

{
"name": "Test Workflow",
"description": "The first workflow, created while following the tutorials"
}
http -> Calling after change function url-http-wait-for-headers-change-function' for#'
http -> url-http-wait-for-headers-change-function ( http host:80-873342)
http -> Saw end of headers... ( http host:80-873342)
http -> url-http-parse-response called in ( http host:80-873342)
http -> Got a content-length, being smart about document end.
http -> Got 0-length content-length, activating callback immediately.
http -> Marking connection as free: host:80 #
http -> url-http-parse-headers called in ( http host:80-873342)
http -> url-http-parse-response called in ( http host:80-873342)
http -> Parsed HTTP headers: class=2 status=201
http -> Finished parsing HTTP headers: t
http -> Marking connection as free: host:80 #
http -> Activating callback in buffer ( http host:80-873342): restclient-http-handle-response (nil "POST" "http://host/gambit/api/workflow" "HTTP Response" nil nil)

So it calls the restclient-http-handle-response but there is where I start losing sight of the problem.

My theory is that because of the minimalistic response from the server, that in the while loop in restclient-prettify-response it's not seeing something it's expecting. "^\s-*$" perhaps? And because of that, it's just looping forever. In my minibuffer, I just get a Contacting host message that doesn't go away unless I C-g a number of times.

Thanks!

Could be related to Issue: #67

Can't use # inside of url

It seems that if I use # in a url, restclient considers the rest of that line a comment.

Workaround is to replace the # with %23 before executing the script.

problems with json-pretty-print-buffer

I'm really new to emacs, as in I've just installed it today. Comming from vim i think modes like this restclient will improve a lot my workflow at work. Here's is my problem.

After pressing C-c C-c here's the error I get:
error in process filter: Symbol's function definition is void: json-pretty-print-buffer

I'm using emacs24 on ubuntu. Maybe I need some dependencies??

Wrong number of arguments

Trying the Twitter example i get the following error message:

HTTP GET http://api.twitter.com/1/statuses/user_timeline.json?screen_name=twitterapi&count=2 Headers:[nil] Body:[]
let*: Wrong number of arguments: #[(url callback &optional cbargs) "Ã� Ä
B#�" [url callback cbargs url-retrieve-internal nil] 5 ("/usr/local/Cellar/emacs/23.3a/share/emacs/23.3/lisp/url/url.elc" . 2366)], 5

HTH

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.