Hi Everybody, Greetings from Colombia.  This is my first Blog.

This is a step by step example of how to setup a Sender RESTAdapter Channel (with the Operation PUT), and how to test it using the Chrome Plugin and a simple JAVA Class.  I won’t explain how to build the Mapping and the other side of the integration.

System: SAP PI 7.4 SP11

This example will follow this workflow:

JAVA <-> PI RESTAdapter (JSON) <-> PI Mapping (XML) <-> PI JDBCAdapter (XML) <-> Oracle SP

Bussiness Case Description

A Java class consumes a REST service published in PI to check if an ID (nmDni) represents a risk to the company.


Message Mapping

The datatype must have a field nmDni, named just like the parameter that we are going to send in the JSON payload.


Communication Channel

We will be working with the Adapter Type REST in the communication channel.  Follow the next screenshots to set up the channel:


General Tab

Here it’s important to set the Element Name with the request Message Type, so the JSON structure can be recognized in the request


Channel Selection Tab


REST Resources Tab

Here it’s very important to set the JSON Element that will match with the datatype defined in PI nmDni


Rest Operation Tab


The last 2 tabs are left empty

  • Operation Determination
  • Error Handling

Activate and assign the channel to the ICO in the Integration Builder.



The ping on the channel, in the Communication Channel Monitor, you can get the endpoint and check the pattern of the parameter that we will use in the testing fase.


Chrome Plugin

Download and install the Advance REST Client plugin for Google Chrome.

Put the endpoint and select the PUT operation.  In the payload section paste this code:





Clic the “Send” button and the response should appear in JSON format 😀


Java Class

Here it’s the Java class that will work to test the REST Service.  It’s important to notice, that you need a PI user and password.  That user and password is encoded using Base64 library.

package com.prueba.rest;

import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.io.OutputStreamWriter;

import java.net.HttpURLConnection;

import java.net.URL;

import sun.misc.BASE64Encoder;

public class PruebaRestMAIN {

    public static void main(String[] args) {

    String name = "pi_username";

        String password = "pi_password";

    String authString = name + ":" + password;

        String authStringEnc = new BASE64Encoder().encode(authString.getBytes());

        System.out.println("Auth string: " + authStringEnc);

        String line;

        StringBuffer jsonString = new StringBuffer();

        try {

            URL url = new URL("http://your_PI_domain:50000/RESTAdapter/riesgosput/1234");

            //escape the double quotes in json string

            String payload="{\"nmDni\":\"71333\"}";

            HttpURLConnection connection = (HttpURLConnection) url.openConnection();




            connection.setRequestProperty("Authorization", "Basic "+authStringEnc);

            connection.setRequestProperty("Accept", "application/json");

            connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");


            OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");



            BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));

            while ((line = br.readLine()) != null) {





        } catch (Exception e) {

                throw new RuntimeException(e.getMessage());



        System.out.println("Respuesta: "+jsonString.toString());





In the PI message monitor you will see the 2 lines for each test.  And if you open the message you will see in the Payload tab the JSON message:


I hope this helps in your way to test the RESTAdapter in PI.

Have a good day

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Husain Dahodwala

    Hi Manuel,

    Thanks for the blog. I have one doubt in my scenario the REST ful service would be triggered by Salesforce. So what do i need to provide the Salesforce team just the complete URl with endpoint?

    How should i define by message type and response message type ? If the incoming data comes as XML then how do we capture the message in our defined message interface

    My question would be naive as I have no clue on REST. Would appreciate if you can help and guide me.





Leave a Reply