Re: Bad request error when using uri-common
On Sun, Sep 20, 2020 at 04:16:55PM +, Brian Hughes wrote: > 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))])) Hi Brian, The path in the snippet above is not an absolute path. > (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_token= >" Note the missing slash between .com and 100055... You can fix this by using path: `(/ ,my-facebook-id) Cheers, Peter signature.asc Description: PGP signature
Bad request error when using uri-common
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_token=" (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_token=") (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.