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?Have tried without the slash at the end of the url.
;; Query parameters
(client/get "" {:query-params {"q" "foo, bar"}})
yes I just tried without the slash. It reaches and gets 200 but google map says my query is invalid.
It is interesting because my curl request doesn't get this complaint.
Have you tried
(client/get
"" ;; removed slash at the end
{:query-params
{"input" "%2B16502530000"
"inputtype" "phonenumber"}}) yes, I just did and got the same complaint.
Sorry, I wonder if there is some header value you need to set?
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. 🙂Maybe try this:
;; save the request that was sent in a :request key in the response:
(client/get "" {:save-request? true}) To see what you sent.
Oh
that must be helpful. let me try
There are different debug modes.
https://github.com/dakrone/clj-http?tab=readme-ov-file#debugging
Ah I found the cause
the library was changing the input value like this
%252B16502530000
what I meant was
%2B16502530000Probably it is because of %?
Is this because normally the % is followed by 2 characters or something like that.
I had wondered if the % was causing the issue - maybe encoding it for a url would help?
Should that be a "+"
i.e. %2B = +
Problem solved. That was it!
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\" :Thanks so much for your help @mmer