Libcurl get params in utf-8?

Hello everyone !!

I am with libcurl doing get to an API and I can pass a filter as a parameter as follows

where={ “nsacrux”: 20}

leaving the url as follows{ “nsacrux”: 20}

the issue that gives me error 400.

Playing with the VCode Thunder Client extension (it’s where I test the API call) it generates the curl and the where does it as follows:


and it stays working if I call with libcurl

how could i solve it?

thank you so much

What does utf-8 have to do with your question?

Hi Mike, it’s nice chatting with you.

When I convert the GET call to curl, the parameter is passed to utf-8

I have tried it with libcurl without converting the parameter to utf-8 and it gives error 400. Maybe it is a mistake or a misinterpretation on my part

That’s not what utf-8 is. This is just encoding the non-URI-friendly characters as hex. The % means that the following 2 characters are hex.

If you can’t find a way to convert that, I have a method here: AmbleScrayLite/Clarion/JS_HexTools.clw at 60a07f7ba808baef995c4a93f3c2763b2f70b6b9 · jslarve/AmbleScrayLite · GitHub

1 Like

that example misses parts of the url after the .com, on the image it can be seen rux?where= , can you confirm the url you tested was complete?

Hi Carlos,

It is not utf-8, it is url encoding. You can use TCurlUrlApiClass or printf to encode:

TCurlUrlApiClass approach:

uapi                          TCurlUrlApiClass
  host = ''
  params = 'where={{ “nsacrux”: 20}'
  uapi.SetPart(CURLUPART_URL, host)
  uapi.GetPart(CURLUPART_URL, url)
  rc = curl.SendRequest(url,...)

printf approach:

  host = ''
  params = 'where={{ “nsacrux”: 20}'
  url = printf('%s?%u', host, params)
  rc = curl.SendRequest(url,...)

Oh! my God!! Sorry for the misconception on my part.

I have learned something new today.

Thank you very much to all !!