How to resolve the error "URLDecoder: Illegal hex characters in escape (%) pattern" in Invoke REST API Activity

How to resolve the error "URLDecoder: Illegal hex characters in escape (%) pattern" in Invoke REST API Activity

book

Article ID: KB0074633

calendar_today

Updated On:

Products Versions
TIBCO ActiveMatrix BusinessWorks Plug-in for REST and JSON 2.1.0

Description

When char '%' is used in the URI or form data field of Invoke REST API activity, below error is thrown:
**********************************
2020 Jun 03 10:18:15:160 GMT +0530 BW.Reprod Error [BW_Plugin] BW-RESTJSON-2000019 Thread_Name[JobCourier7] Process_Id[124000] Activity_Name[Invoke REST API] Error happened when invoking REST server, [ URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "zs" ] 
2020 Jun 03 10:18:15:183 GMT +0530 BW.Reprod Error [BW_Plugin] BW-RESTJSON-2000019 Job-124000 Error in [NormalInvoke.process/Invoke REST API]
Error happened when invoking REST server, [ URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "ur" ]
    at com.tibco.plugin.json.activities.RestActivity.eval(RestActivity.java:457)
    at com.tibco.pe.plugin.Activity.eval(Unknown Source)
    at com.tibco.pe.core.TaskImpl.eval(Unknown Source)
    at com.tibco.pe.core.Job.a(Unknown Source)
    at com.tibco.pe.core.Job.k(Unknown Source)
    at com.tibco.pe.core.JobDispatcher$JobCourier.a(Unknown Source)
    at com.tibco.pe.core.JobDispatcher$JobCourier.run(Unknown Source)

**********************************

Issue/Introduction

Resolving error "URLDecoder: Illegal hex characters in escape (%) pattern" we get in Invoke REST API activity.

Environment

ALL

Resolution

Char % is used as an escape char with HEX representation of char to encode special characters in URL. So when char % is used in URL or Form Data, it needs to be encoded with %25 to resolve the above mentioned error. For example, if the url is 'http://localhost:1234/testurl/v1/api/user/adhorwb%zsHasj' having % char than we need to replace % char with %25 which transforms the url to 'http://localhost:1234/testurl/v1/api/user/adhorwb%25zsHasj'.

The reason for encoding the form data for char % is that the default content-type is 'application/x-www-form-urlencoded' when form data is used. So the special characters also needed to be encoded. Alternate to encode the % char in form data to resolve the issue, the form data can be send using Multipart.

Attachments

How to resolve the error "URLDecoder: Illegal hex characters in escape (%) pattern" in Invoke REST API Activity get_app