Error Using Drakma for Bing Common Lisp Search APIs

I am creating a program that uses the Bing search API and a generic lisp with the Drakma library to display some results, but for some reason has an error sending a longer request. It does not display any results at all, It works for shorter length queries. I am using a temporary account for this question. I have the following code.

(defun get-rid-of-spaces (var)
 (cl-ppcre:regex-replace-all " " var "%20"))


(defun print-bing (search-term)
  (format nil "https://api.datamarket.azure.com/Bing/Search/v1/Web?Query=%27~a%27&Options=%27DisableLocationDetection%27&$format=json&$top=1" (get-rid-of-spaces search-term)))

(defun drakma-bing (search-term)
 (drakma:http-request (print-bing search-term)
           :basic-authorization
           '("bob.hammerston@mailinator.com" "L2gbaj+s1/KW/+ifAa9HrP0C1/kClpF4InH48Lw8UNc")))

(defun convert-to-string (response)
 (map 'string #'code-char response))

And then I call it, but it only works for short searches, and I can’t understand why. This does not work:

(convert-to-string (drakma-bing "what is the largest man in the world"))

But it does

(convert-to-string (drakma-bing "what is"))

Any idea why?

Thanks.

Edit:

print-bing , , Drakma . - , , , Drakma.

+4
1

+ %20.

(defun get-rid-of-spaces (var)
 (cl-ppcre:regex-replace-all " " var "+"))
+5

Source: https://habr.com/ru/post/1625671/


All Articles