cancel
Showing results for 
Search instead for 
Did you mean: 

REST Sender Adapter Error(Failed to convert request body format: JSON-to-XML conversion failed: Source content is not a valid JSON object: A JSONObject text must begin with '{' at 1 [character 2 line 1]”.)

Former Member
0 Kudos

Hi,

I have configured the Interface between Mobile App & SAP ECC systems via SAP PI. Using the REST Sender adapter to communicate the Mobile App with SAP PI system & Receiver side using the RFC Adapter to communicate with SAP ECC For Request & Response messages(Synchronous interface).

Please clarify me the below things & share me any Document:

1. Let me know the procedure how to test the POST URL to communicate Mobile Apps with SAP PI.

2. How to generate the HTTP request(URL) using the REST sender adapter for communicating the Mobile Application.

The below error message i am getting in Communication channel in Runtime workbench.

Failed to convert request body format: JSON-to-XML conversion failed: Source content is not a valid JSON object: A JSONObject text must begin with '{' at 1 [character 2 line 1]”.

Thanks & Best Regards,

Vishnu


Accepted Solutions (0)

Answers (1)

Answers (1)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Vishnu,

                 Each REST web service has its own xml message format. In request you need to specify the mode or method of communication such as GET /POST/PUT etc. From the error it seems web service is expecting XML request. REST being a client server architecture will accept request over socket communication. You can write a sample java code to communicate with REST webservice

String request = "http://api.xyz.com/WebService/webS";

    HttpClient client = new HttpClient();

    PostMethod method = new PostMethod(request);

    // Add POST parameters

    method.addParameter("id","userDemo");

    method.addParameter("query","hat");

    // Send POST request

    int statusCode = client.executeMethod(method);

    InputStream in = null;

   

    // Get the response body

  in = method.getResponseBodyAsStream();

In the adapter you need to pass parameters, similarly ,to get the response from the web service.

Regards

Anupam

Former Member
0 Kudos

Hi Anupam,

Thanks for your Response.

Here we are working on PI 7.1 version & Bought the Rest Adapter from Advantaco. Here we are using standard adapter modules like:

Module Names:

CustomModule1,CustomModule2,CallSapAdapter.

Type:

Local  Enterprise  Bean - for all module names

Module Key:

md1,md2,exit

Is it require to develop Java code to communicate with restadapter or Existing standard modules is enough.

Please share me if you have any documents to implement this kind of interfaces.

Regards

Vishnu

anupam_ghosh2
Active Contributor
0 Kudos

Hi Vishnu,

                   I have not worked with REST adapter but used java codes to communicate. I guess the parameters used in normal java code to communicate with REST web service will be present in some form in the REST adapter. Could you provide me a screen shot or the list of parameters you need to supply in REST adapter? Then I can try suggesting the options.

Regards

Anupam