clj-http

kokonut 2024-01-25T14:58:57.815079Z

hi I am trying to make a get request like the following in clj-http.


  ?input=%2B16502530000
  &inputtype=phonenumber
When I use cUrl, it works well like below
curl -L -X GET ''
But I am not going through with my clojure code using clj-http.
(client/get
 "" ;; removed slash at the end
 {:query-params
  {:input "%2B16502530000"
   :inputtype "phonenumber"}})
Can someone enlighten me what I am doing wrong?

mmer 2024-01-25T15:02:44.683579Z

Have tried without the slash at the end of the url.

mmer 2024-01-25T15:03:02.977029Z

;; Query parameters
(client/get "" {:query-params {"q" "foo, bar"}})

kokonut 2024-01-25T15:04:52.338439Z

yes I just tried without the slash. It reaches and gets 200 but google map says my query is invalid.

kokonut 2024-01-25T15:06:11.065339Z

It is interesting because my curl request doesn't get this complaint.

mmer 2024-01-25T15:10:07.328299Z

Have you tried

(client/get
 "" ;; removed slash at the end
 {:query-params
  {"input" "%2B16502530000"
   "inputtype" "phonenumber"}})

kokonut 2024-01-25T15:26:35.468559Z

yes, I just did and got the same complaint.

mmer 2024-01-25T15:27:05.604709Z

Sorry, I wonder if there is some header value you need to set?

kokonut 2024-01-25T15:32:08.540919Z

Don't be. It's a headache. But I just did put all params in the url string like curl

(client/get 
"")
and it works! I know it looks primitive but it's important that it works. 🙂

mmer 2024-01-25T15:35:20.653549Z

Maybe try this:

;; save the request that was sent in a :request key in the response:
(client/get "" {:save-request? true})

mmer 2024-01-25T15:35:28.449739Z

To see what you sent.

kokonut 2024-01-25T15:35:51.225209Z

Oh

kokonut 2024-01-25T15:35:57.850289Z

that must be helpful. let me try

mmer 2024-01-25T15:36:18.997789Z

There are different debug modes.

kokonut 2024-01-25T15:38:45.299399Z

Ah I found the cause

👍 1
kokonut 2024-01-25T15:39:26.422129Z

the library was changing the input value like this

%252B16502530000
what I meant was
%2B16502530000

kokonut 2024-01-25T15:40:13.203759Z

Probably it is because of %?

mmer 2024-01-25T15:41:10.115879Z

Is this because normally the % is followed by 2 characters or something like that.

mmer 2024-01-25T15:42:19.696249Z

I had wondered if the % was causing the issue - maybe encoding it for a url would help?

mmer 2024-01-25T15:43:32.757259Z

Should that be a "+"

mmer 2024-01-25T15:43:51.974409Z

i.e. %2B = +

kokonut 2024-01-25T15:46:01.965169Z

Problem solved. That was it!

👍 1
kokonut 2024-01-25T15:46:23.518079Z

I am getting these data successfully

;;     :body
;;     "{\n   \"candidates\" : \n   [\n      {\n         \"place_id\" : \"ChIJj61dQgK6j4AR4GeTYWZsKWw\"\n      },\n      {\n         \"place_id\" : \"ChIJ2Xz75-t5j4ARB2DdjJy2uqA\"\n      },\n      {\n         \"place_id\" : \"ChIJC_TKnI84K4gR7PNbCsldD0c\"\n      },\n      {\n         \"place_id\" : \"ChIJyesLCqa3j4ARxZkBe9Qt_mk\"\n      },\n      {\n         \"place_id\" : \"ChIJhbgMV7dhK4gR33wqaPHOCuQ\"\n      },\n      {\n         \"place_id\" :

kokonut 2024-01-25T15:46:35.040709Z

Thanks so much for your help @mmer