From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Thierry Leurent Newsgroups: gmane.emacs.help Subject: Re: How to send a request to a Website. Date: Thu, 20 Apr 2017 20:07:26 +0200 Message-ID: <1606625.JQzgEmpUZe@e6430> References: <2320801.DznD1DNTWb@e6430> <2453198.OlclnZDYAl@e6430> <87o9vr0z7a.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit X-Trace: blaine.gmane.org 1492711848 7178 195.159.176.226 (20 Apr 2017 18:10:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 20 Apr 2017 18:10:48 +0000 (UTC) User-Agent: KMail/5.2.3 (Linux/4.9.0-2-amd64; KDE/5.28.0; x86_64; ; ) 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 20:10:44 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 1d1GXT-0001h4-53 for geh-help-gnu-emacs@m.gmane.org; Thu, 20 Apr 2017 20:10:43 +0200 Original-Received: from localhost ([::1]:55358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1GXV-0000Uh-Pq for geh-help-gnu-emacs@m.gmane.org; Thu, 20 Apr 2017 14:10:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1GUQ-0006xQ-DG for help-gnu-emacs@gnu.org; Thu, 20 Apr 2017 14:07:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1GUN-0008PA-9E for help-gnu-emacs@gnu.org; Thu, 20 Apr 2017 14:07:34 -0400 Original-Received: from 5.mo3.mail-out.ovh.net ([87.98.178.36]:36245) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1GUN-0008OK-27 for help-gnu-emacs@gnu.org; Thu, 20 Apr 2017 14:07:31 -0400 Original-Received: from player758.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id 68028C8A3E for ; Thu, 20 Apr 2017 20:07:27 +0200 (CEST) Original-Received: from e6430.localnet (200.27-200-80.adsl-dyn.isp.belgacom.be [80.200.27.200]) (Authenticated sender: thierry.leurent@asgardian.be) by player758.ha.ovh.net (Postfix) with ESMTPSA id 5796E2C0077 for ; Thu, 20 Apr 2017 20:07:27 +0200 (CEST) In-Reply-To: <87o9vr0z7a.fsf@ericabrahamsen.net> X-Ovh-Tracer-Id: 17933052242145588182 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeliedrfedvgdduvddvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenuc X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.178.36 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:112824 Archived-At: It's great.... ;). You help-me too understand lisp On Thursday, April 20, 2017 10:24:25 AM CEST Eric Abrahamsen wrote: > 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 -- Thierry Leurent