From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Kevin Buchs Newsgroups: gmane.emacs.help Subject: Re: How to send a request to a Website. Date: Thu, 20 Apr 2017 18:15:59 +0000 Message-ID: References: <2320801.DznD1DNTWb@e6430> <87fuh386z7.fsf@ericabrahamsen.net> <2453198.OlclnZDYAl@e6430> <87o9vr0z7a.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1492712199 5022 195.159.176.226 (20 Apr 2017 18:16:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 20 Apr 2017 18:16:39 +0000 (UTC) To: Eric Abrahamsen , 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:16:35 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 1d1Gd8-0001Aa-Qa for geh-help-gnu-emacs@m.gmane.org; Thu, 20 Apr 2017 20:16:34 +0200 Original-Received: from localhost ([::1]:55388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1GdD-0004c3-1t for geh-help-gnu-emacs@m.gmane.org; Thu, 20 Apr 2017 14:16:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Gcm-0004ah-Ak for help-gnu-emacs@gnu.org; Thu, 20 Apr 2017 14:16:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1Gck-0002sd-QI for help-gnu-emacs@gnu.org; Thu, 20 Apr 2017 14:16:12 -0400 Original-Received: from mail-ua0-x231.google.com ([2607:f8b0:400c:c08::231]:36107) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d1Gck-0002sX-KD for help-gnu-emacs@gnu.org; Thu, 20 Apr 2017 14:16:10 -0400 Original-Received: by mail-ua0-x231.google.com with SMTP id a1so60452711uaf.3 for ; Thu, 20 Apr 2017 11:16:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=WY1x7tGtk9cIBl9iN6l2l0Bv2j5xnz/Zbk927U7AN5Q=; b=iYlSjYUTlP3skF/zVq7qBtHb8HuhBCQE1GszcENxaE7SBdfbYjMeu16qc7gYsvyGMU 33pUJg4Ri2eNtmQDP/NseaPBHgskLHbth+Mk1b3Ugu1MB7fnNM4MErxTQecS1xqWIOD+ 6bwJsIU7acBeYtUaZaKxd9PPyXjiiA1xM9HGoPA3w2peaNBXY6N5iEkaAmwwjZRiTcVc D/Wc9RKSBKPz5jNAtRrWGCzEuqcCDZTyZlomzSMiGpiTZayCA9Mvb9dobQVXflpv6x6u ahMR5EBzNxN9BsfOo+eIanLu0N6+u0tGutQfzDXYBAOKs0AZJT17SDmMKcKda3r9/Imp Ohjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=WY1x7tGtk9cIBl9iN6l2l0Bv2j5xnz/Zbk927U7AN5Q=; b=MAJTalJLHCvsYGV49nP138M9mlWMsfB/xVBZ0n8KjKGYLcQm+MGGKZMJ0ZlXvSqWtK VSkLMp+7rNhJFUxlS4MqlwNVJaDxY1cFFRpENgx9tP2xNlrnN8PU5uVNvaFxfGh++gZy bn96IVvpFcI7DF6hSNq7bSrs7zruzzPHlm8zG/MoIiqHlUH+2lHh2vTfefoB3vyoL3Ji HyfqyV+tjh8Sm23Old7iM2aGZhsNbM6yI7BTBKA8e2p9lcyWBeBQdm6IBVQf4h6OJAG5 HK+ZjtA9xjF3hHW1O19WQH3CmwLfeIohXkHPrtViPROG+ZRs3wYQWVlg/PP23TkLQHOd rHVA== X-Gm-Message-State: AN3rC/6iyPN4yFJKHyySB6iHxKaAUp4jyi72DWVlZCorcN4lZfBLkXMd fv7km0fQOdK7Iv9oP3DOZJEC0QHPZk1O X-Received: by 10.31.85.5 with SMTP id j5mr3625869vkb.167.1492712169776; Thu, 20 Apr 2017 11:16:09 -0700 (PDT) In-Reply-To: <87o9vr0z7a.fsf@ericabrahamsen.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400c:c08::231 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:112825 Archived-At: I was trying to understand how your code could work, but the HTTP 401 status suggested it was working, partially at least. One item that stood out was that you hardcoded the SAML token. I would expect that would only expire after some time. So maybe the rest of your code does the token request and you gave us an example token. I'd suggest you make the changes Eric proposed and then give us the code and the response you got. If you are using the token as a variable and not hardcoded please send corresponding code. On Thu, Apr 20, 2017 at 10:24 AM 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 > > >