Arabic Characters

Mariusz
Mariusz Newcomer
edited March 31 in Screening

Below is my payload, the name is Arabic when I send it with HTTP client I'm getting unauthorized. When the name is in English, same body work fine. Why? Can somebody tell me how to solve it.

{"groupId":"0000000000000","entityType":"ORGANISATION","caseId":"ORG-00000800","providerTypes":["CLIENT_WATCHLIST","WATCHLIST"],"caseScreeningState":{"WATCHLIST":"ONGOING"},"name":"الشركة تكون","nameTransposition":false,"secondaryFields":[{"typeId":"SFCT_6","value":"BEL"}],"customFields":[]}

Code.

public string WorldCheckPostData(string data, string firstPart, string firstValue = null, string secondPart = null, string secondValue = null)
{
HttpResponseMessage response = null;
string urlSecondPart = CreateNewString(firstPart, firstValue, secondPart, secondValue);
Uri uri = new Uri($"{_baseUrl}{urlSecondPart}");
try
{
using (var client = new HttpClient())
{
HttpMethod httpMethod = HttpMethod.Post;
Encoding encoding = Encoding.UTF8;
HttpRequestMessage httpRequest = GenerateHTTPRequest(uri, httpMethod, data);
//httpRequest.Content = new StringContent(data, encoding, _contentType);
httpRequest.Content = new StringContent(data, encoding, _contentType);
httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(_contentType);
response = client.SendAsync(httpRequest).GetAwaiter().GetResult();
if (!response.IsSuccessStatusCode)
{
var message = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
throw new Exception($"World Check POST method field with exception: { message }");
}
httpRequest.Dispose();
}
}
catch (Exception)
{
throw;
}
return response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
}

Answers

  • Hi @Mariusz,

    Thank you for reaching out, When making API requests to World-Check One with Arabic names or names containing special characters, it's essential to ensure that the request payload is encoded in 'utf-8' . This helps generate the correct content-length, preventing error 401. Incorrect content-length can lead to authentication errors and failed requests.

    If you need further assistance to handle these scenarios, please provide your email ID, and I'll be happy to send you the necessary sample codes.

    Thanks,
    Ram