[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bad request error when using uri-common
From: |
Brian Hughes |
Subject: |
Bad request error when using uri-common |
Date: |
Sun, 20 Sep 2020 16:16:55 +0000 |
Hi everyone,
I recently got started using http-request and uri-common to access the
facebook API. Everything generally works, but I encountered some
unexpected behavior when using uri-common's make-uri that I'd like some
help with. I'd rather be using make-uri than building strings in my
code.
This first fragment throws an error:
(form-urlencoded-separator "&")
(define foo (make-uri scheme: 'https
host: "graph.facebook.com"
path: `(,my-facebook-id)
query: `[(fields . "name")
(access_token . ,(get-app-access-
token))]))
(display (with-input-from-request foo #f read-json))
Output:
$ csi -s fb.scm
Error: (call-with-input-request) Client error: 400 Bad Request: "
https://graph.facebook.com100055065685451?fields=name&access_token=<redacted
>"
(stack trace omitted)
Is the missing / just in the error message, or would that be what is
sent out on the network? I'd expect the DNS lookup to fail if this was
the actual problem but that's not the error I'm getting.
If I paste the URL in the error string (and add / after .com) and pass
it to with-input-from-request, it works fine:
(define foo-string "
https://graph.facebook.com/100055065685451?fields=name&access_token=<redacted
,matches above>")
(display (with-input-from-request foo-string #f read-json))
Output:
$ csi -s fb.scm
((name . Brian Hughes) (id . 100055065685451))
How can I get the make-uri version to work?
Thanks in advance.
- Bad request error when using uri-common,
Brian Hughes <=