cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CPI : externalized parameter to the HTTP adapter with special characters for an API call

amit_mane
Discoverer
0 Kudos
952

Dear community members,

I'm quite new to the SAP CPI world and learning many new things with the time.

As per my requirement I need to use external parameters using content modifier to the HTTP adapter for making a dynamic query API call to the Microsoft Graph. With my current implementation I'm able to do so only for the integer value parameters successfully (without using any script). But when it comes to the parameter value with alphanumeric including special characters then I'm facing an issue. (Example-'ABC_12345_XYZ')

For this reason, I tried to use Groovy script for implementing a query encoding (in UTF-8) due to special characters, also tried inline query encoding, but unable to get desired result.

Could you please guide me, what else I can do in this case?

Below is an used Groovy script for the reference,

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import org.apache.http.client.utils.URIBuilder

def mailNickname = exchange.getProperty("mailNickname")

if (mailNickname) {
    def encodedMailNickname = new URIBuilder().setParameter("param", mailNickname).build().getQuery()
    exchange.setProperty("mailNickname", encodedMailNickname)
} else {
    throw new Exception("mailNickname property not found.")
}

/*

if (mailNickname) {
    def encodedMailNickname = URLEncoder.encode(mailNickname, 'UTF-8')
    message.setProperty("mailNickname", encodedMailNickname)
} else {
    throw new Exception("mailNickname property not found.")
}

*/


Thank you in advance and appreaciate your answers.

Accepted Solutions (0)

Answers (1)

Answers (1)

VijayKonam
Active Contributor
0 Kudos

But when it comes to the parameter value with alphanumeric including special characters then I'm facing an issue. (Example-'ABC_12345_XYZ')

What is the issue? As far as I know, it should not matter if there an alpha char or a special character in the externalized parameter.