all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Buchs <kevin.buchs@gmail.com>
To: Eric Abrahamsen <eric@ericabrahamsen.net>, help-gnu-emacs@gnu.org
Subject: Re: How to send a request to a Website.
Date: Thu, 20 Apr 2017 18:15:59 +0000	[thread overview]
Message-ID: <CAKT9s6DTYEH=3En89ZeStqhiSj6x=C5OVf+gyr8Qh=ZqdYnnqg@mail.gmail.com> (raw)
In-Reply-To: <87o9vr0z7a.fsf@ericabrahamsen.net>

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 <eric@ericabrahamsen.net>
wrote:

> Thierry Leurent <thierry.leurent@asgardian.be> 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
>
>
>


  parent reply	other threads:[~2017-04-20 18:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20 10:59 How to send a request to a Website Thierry Leurent
2017-04-20 14:54 ` Eric Abrahamsen
2017-04-20 17:02   ` Thierry Leurent
2017-04-20 17:24     ` Eric Abrahamsen
2017-04-20 18:07       ` Thierry Leurent
2017-04-20 18:15       ` Kevin Buchs [this message]
2017-04-20 21:22         ` Thierry Leurent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKT9s6DTYEH=3En89ZeStqhiSj6x=C5OVf+gyr8Qh=ZqdYnnqg@mail.gmail.com' \
    --to=kevin.buchs@gmail.com \
    --cc=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.