From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: How to send a request to a Website. Date: Thu, 20 Apr 2017 10:24:25 -0700 Message-ID: <87o9vr0z7a.fsf@ericabrahamsen.net> References: <2320801.DznD1DNTWb@e6430> <87fuh386z7.fsf@ericabrahamsen.net> <2453198.OlclnZDYAl@e6430> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1492709109 3413 195.159.176.226 (20 Apr 2017 17:25:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 20 Apr 2017 17:25:09 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 20 19:25:04 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1FpI-0000dk-1Q for geh-help-gnu-emacs@m.gmane.org; Thu, 20 Apr 2017 19:25:04 +0200 Original-Received: from localhost ([::1]:55219 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1FpI-0003XG-SD for geh-help-gnu-emacs@m.gmane.org; Thu, 20 Apr 2017 13:25:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Fos-0003Wu-P9 for help-gnu-emacs@gnu.org; Thu, 20 Apr 2017 13:24:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1Fop-0001kQ-Jm for help-gnu-emacs@gnu.org; Thu, 20 Apr 2017 13:24:38 -0400 Original-Received: from [195.159.176.226] (port=50881 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d1Fop-0001kG-DD for help-gnu-emacs@gnu.org; Thu, 20 Apr 2017 13:24:35 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1d1Foh-0008Sp-9j for help-gnu-emacs@gnu.org; Thu, 20 Apr 2017 19:24:27 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 33 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:BrayVSrChVmUW1cj11sCjr7AjTc= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112823 Archived-At: Thierry Leurent writes: > Thank you your help but it don't work. > > It's not a syntax problem. > The code return a result. IMHO, it's a trouble with the content of the http > request. > I'm not an lisp programmer and I have some trouble to understand how the code > work. Okay sorry, I was just fixing the obvious lisp errors in your example, I didn't actually try the code. `url-retrieve-synchronously' returns a buffer containing the URL contents, not the data itself. So it should look like this: (require 'url) (require 'url-http) (require 'json) (defvar data-buffer (let ((url-request-method "POST") (url-request-extra-headers `(("Content-Type" . "application/x-www-form-urlencoded") ("Authorization" . "bearer 1zzpkqkabx2v424kjn8yqmfjhywzny6sn2bmb7kt"))) (url-request-data (json-encode '(:title "Post using emacs.")))) (url-retrieve-synchronously "https://asgardian.be/WordPress/wp-json/wp/v2/posts?state=1234&access_token=1zzpkqkabx2v424kjn8yqmfjhywzny6sn2bmb7kt"))) (display-buffer data-buffer) If there's something wrong with the actual authorization process, of course, I won't be able to help with that. But to my knowledge the above should be the equivalent of the Python code you posted. Eric