Getting 400 error (Bad Request) when hitting api response contains umlaut (german language) as one of the parameter

I have installed Katalon 5.5 in my machine. I tried to hit api which contains umlaut characters (German language) has one of the parameter and it is throwing 400 bad request error. But the same api is working fine in Soapui version 5.4.0

Please send us your request file (.rs file).
Regards

I am experiencing something similar here: When sending a request which contains an umlaut in the search string (“zür”) from the object repository I am getting a response with the content I am expecting (I don’t mind the garbled display in the reponse field):

When I send the same request with the same search string from the testcase I am getting an empty response:

Request:

Reponse:

The same request is working in Postman and in Swagger. Any hints?

Hi @marcel.a,
Please send us the HAR file logged in the console view

If you mind the garbled characters, there is a fix for it. See

Hi @huynguyen

Please find attached the two HAR files. The one for the request from object repositry which delivers a good response, and also the one from the testcase which delivers a “faulty” response…

Thanks,
MarcelReqTestcase.har (3.6 KB)
ReqObjRep.har (35.9 KB)

Hi @kazurayam

Thanks for your response, I’ll try that after my initial problem is solved.

Cheers,
Marcel

The umlaut may be garbled in the request. It may cause 400 Bard Request error. So I would suggest to you to fix encoding problem first.

Hi @marcel.a,
I can see from the har file that your requests sent from your test case script and from the Object Repository differs in Authorization header value. Can it be the reason why the responses are different for the two requests?
Regards.

Hi @huynguyen

Thanks for getting back to that topic.
No, I don’t think the authorization header makes the difference. In the meantime I managed to get the test cases working. When encoding the Umlaute with percent-encoding aka URL-encoding (https://en.wikipedia.org/wiki/Percent-encoding) it works. Somehow the requests made from the object repositry seems to handle the encoding automatically.

I happened to come back to this problem. I could reproduce how you got the garbled display. Please see the following test case script.

import java.nio.charset.StandardCharsets

String germanString1 = 'zür'
byte[] encodedBytes = germanString1.getBytes(StandardCharsets.UTF_8);
String decodedString = new String(encodedBytes, StandardCharsets.ISO_8859_1);
println(germanString1 + " -> " + decodedString)

When I ran this, I got the following output in the log:

2020-12-28 22:13:55.299 DEBUG testcase.TC2                             - 4: println(germanString1 + " -> " + decodedString)
zür -> zür

You can find zür in the screenshot (in the Response body) as well. This proves, some portion of your software has a bug; but I have no clue to identify which particular portion of your software has this problem.

I guess as follows:

Katalon Studio uses utf-8 for character encoding. You can see the reason in the post “Katalon.ini should speciify -Dfile.encoding=utf-8 - #10 by kazurayam”.

So the zür character string in UNICODE, which you typed in the GUI, is encoded into byte in the Request object using UTF-8. The request object carries that byte to your web app.

Your web app received the request and decoded the byte in the Request object using mistakenly in ISO-8859-1; at this timing the umlaut character is garbled: the umlaut character in utf-8 is decoded into a strange UNICODE character ü.