Special characters parsing in Ktor - ktor

I am trying to parse some special characters through the api's with Ktor in a KMM project but it seems like Ktor doesn't support it ?.
For eg :- I am trying to parse "Saut� Pans" here "�" is a special character and Ktor throws an exception saying :- io.ktor.utils.io.charsets.MalformedInputException: Input length = 1. Now I have tried passing different headers for example passing different ContentType to UTF-8 or ISO-8859-2 but didn't help.
Whereas parsing the same api response with Gson() works for me.
Any solution or workaround so that for now so that I can parse such kind of special characters in my response ?

You could try out
install(ContentEncoding){
gzip()
}

Related

Getting illegal character when sending GET request in JMETER. Working fine in browser

Im getting illegal character in JMETER for GET request -
https://dev1/api/v1/query/job/?filter={%22job_manager_id%22:%22553f2350-12d3-4252-8fe0-39691019c495%22}
tried replacing %22 with "" but still getting illegal character.
Any solutions ?
I think problematic characters are { and }, they need to be percent-encoded
The options are in:
Tick "URL-encode" box next to the filter parameter in the HTTP Request sampler :
Use __urlencode() function in "Path" field like
see Apache JMeter Functions - An Introduction article to learn more about JMeter Functions concept
Or just hard-code the percent-encoded Path part like:
https://dev1/api/v1/query/job/?filter=%7B%22job_manager_id%22%3A%22553f2350-12d3-4252-8fe0-39691019c495%22%7D

Karate : How to send query param without url encoding

I'm currently writing Automated REST API tests using Karate dsl and I'm encountering an issue when I try a kind of destructive test. Sending invalid query parameter.
I follow the recommendation from this post Karate: Query Param values are getting encoded who is to use the url only but it seems to not work with query parameter:
Scenario: Destructive testing - Illegal characters in parameters or payload
* def buildURL = 'http://127.0.0.1/identity/client?query={"idClient":{"$eq":9223372036854775807}}'
Given url buildURL
When method GET
Then status 400
error:
java.net.URISyntaxException: Illegal character in query at index 39: http://127.0.0.1/identity/client?query={"idClient":{"$eq":9223372036854775807}}
I have the same kind of test for url path where it works fine, but for query param, this way does not seems to work.
To be clear, my goal is to send query params or at least the character { without url encoding
Any idea to solve that ?
Thanks in advance
karate version : 0.9.6
First, you are trying illegal characters as per the spec, so you may need to manually "URL-encode" the URL - and you already seem to be aware of all this, based on the link in your question. Maybe your server is not compliant with the spec.
Recommend you try upgrading to 1.0 and also refer this open issue: https://github.com/intuit/karate/issues/1561
Anything beyond this will require you to help / contribute code.

JMeter encode URL

I have to test the below URL that contains special char:
url\search.html?q=*&Filters=template_fac_s:3f87222389034212a868c5c0cd12cacc|market_l1_fac_sm:e73956c2506442399dd73ed1eb0ec165
I am getting this error:
Response message: Non HTTP response message: Illegal character in query at index 121: url/search.html?q=*&Filters=template_fac_s:3f87222389034212a868c5c0cd12cacc|market_l1_fac_sm:e73956c2506442399dd73ed1eb0ec165
I think I need to encode the URL but I do not know how to do it . Does anyone know how to do this , can someone help.
Thanks.
JMeter provides __urlencode function which replaces characters which are not allowed in URL with url-encoded equivalents
References:
Understanding HTML Form Encoding: URL Encoded and Multipart Forms
Apache JMeter Functions - An Introduction

Unable to upload multipart file in karate, Required request part '' not present

ActualAPIRequest OutputFromKarate
Trying to upload a json file for an api using karate. Since api takes multipart input i am passing multipart configurations in karate.
But Required request part 'inputData' not present error is coming. Is there any solution for this please?
I have attached actual input and result from karate screenshot for reference
Just make sure that the data type of inputData and maybe swaggerFile is JSON. Looks like you are sending a string.
Please refer to this section of the doc: https://github.com/intuit/karate#type-conversion
If the server does not like the charset being sent for each multipart, try * configure charset = null

mule multi language data transfer support via http

I wanna help in achieving below mule use-case.Mule flow contains http-inbound-endpoint and object-string transformer(optional) and logger which prints the payload.
Requirement is that i am invoking flow with rest client with a json string
{
"name":"ساختبار",
"age":"25"
}
in the json string name can of different language for example Arabic language string.
I tried with same implementation with sample json string with name defined in Arabic input string from rest client.But while checking the logger output prints
{
"name":"???????",
"age":"25"
}
instead of actual input.
How i can get the actual Arabic or any language input string printed in logger.
As per forum, set the correct Eclipse console encoding following these instructions and set the appropiate encoding on your endpoints.