Skip to main content
Solved

Encoding of diacritics in HTTPCaller


friesewoudloper
Forum|alt.badge.img

When I do this api request using an HTTPCaller:

https://ckan.dataplatform.nl/api/3/action/tag_show?id=enquête

I get this error:

HTTPCaller_7(HTTPFactory): Received HTTP response header: 'HTTP/1.0 400 Bad request' from 'https://ckan.dataplatform.nl/api/3/action/tag_show?id=enquête'

When I do the same request from within my browser (Chrome and Firefox), I don't get an error.

I tried adding header parameters to my request:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding: gzip, deflate, br Accept-Language: nl,en-US;q=0.7,en;q=0.3

But this didn't work.

Something is going wrong when HTTPCaller encodes diacritics. How do I fix this?

Best answer by david_r

You have two options.

Either pass the parameter values through the TextEncoder set to URL-encoding first:

Or pass them through the query string parameters in the HTTPCaller, it will do the encoding for you:

View original
Did this help you find an answer to your question?

2 replies

david_r
Evangelist
  • Best Answer
  • October 17, 2018

You have two options.

Either pass the parameter values through the TextEncoder set to URL-encoding first:

Or pass them through the query string parameters in the HTTPCaller, it will do the encoding for you:


nielsgerrits
VIP
Forum|alt.badge.img+53
david_r wrote:

You have two options.

Either pass the parameter values through the TextEncoder set to URL-encoding first:

Or pass them through the query string parameters in the HTTPCaller, it will do the encoding for you:

Exactly this. In 2016 the body needs to be encoded too. Took me a while to find out strange API responses. Worked in test, failed in prod, no usable feedback :-)

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings