0

I have the following Emacs Lisp which builds up a query to Freebase. If I copy and paste the URL it generates into my browser OR a commandline curl I get the results I would expect:

curl -X GET https://www.googleapis.com/freebase/v1/search?query=Oil%20on%20Canvas&filter=(any%20type%3avisual_art%2fvisual_art_medium) ... this works.

but I can't make it work from within Emacs:

(require 'url)
(defvar fb-url "https://www.googleapis.com/freebase/v1/search")

(defvar materials-type "(any type:visual_art/visual_art_medium)")

(defun fbquery (type str)
  (let ((url-request-method "GET")


        (url-request-data (concat "?query=" (url-hexify-string str)
                                  "&filter=" (url-hexify-string type))))
    (url-retrieve (concat fb-url)
                  (lambda (status) (switch-to-buffer (current-buffer))))))

(setq url-debug t)

(fbquery materials-type "Oil on Canvas")

I get back:

HTTP/1.0 400 Bad Request ... Your client has issued a malformed or illegal request. That's all we know..

Can you help?

Joe Corneli
  • 642
  • 1
  • 6
  • 18

1 Answers1

1

It seems like the problem is related to intepretation of variable url-request-data

Following code works for me

(defun fbquery (type str)
  (let ((url-request-method "GET")
        (foo (concat "?query=" (url-hexify-string str)
                     "&filter=" (url-hexify-string type))))
    (url-retrieve (concat fb-url foo)
                  (lambda (status) (switch-to-buffer (current-buffer))))))

Please note that I renamed that variable (to avoid the error) and concat-ed it to url

juanleon
  • 9,220
  • 30
  • 41