cancel
Showing results for 
Search instead for 
Did you mean: 

REST Receiver adapter XML to JSON conventer Problems number value - SF LMS

0 Kudos

Hi,

We want to send data to SuccessFactors LMS using PI Rest adapter.

Unfortunately, we are having problems when Rest adapter converts xml to json.

LMS ODATA StudentID

<Property Name="studentID" Type="Edm.String" MaxLength="999999999" Precision="0"/>

StudentID datatype is String in SF LMS.

SAP system sends these data as number. Rest adapter converts this to JSON integer:

XML

<studentID>66777</studentID>

JSON

"studentID": 66777

LMS system wants JSON like this:


"studentID": "66777"

We have tried Java mapping and module development, however Rest adapter gave errors.

How can we workaround this adapter bug?

ERROR

XML

<?xml version="1.0" encoding="utf-8"?>

<STUDENT_DATA odata.type="String 1" xmlns:prx="urn:sap.com:proxy:AHD:/1SAI/TAS247C1D037C6F789A7507:731">

    <studentID>66733</studentID>

    <firstName>Rıdvan</firstName>

    <lastName>Cakir</lastName>

    <timeZone>Europe/Athens</timeZone>

    <currencyID>TRY</currencyID>

    <studentPhones>

        <phoneDescription>cell</phoneDescription>

        <phoneNumber>551-551-02-05</phoneNumber>

    </studentPhones>

    <studentPhones>

        <phoneDescription>home</phoneDescription>

        <phoneNumber>551-551-02-05</phoneNumber>

    </studentPhones>

</STUDENT_DATA>

JSON

{

   "@odata.type": "#Users",

  "studentID": 66733,

   "firstName": "Rıdvan",

   "lastName": "Cakir",

   "timeZone": "Europe/Athens",

   "currencyID": "TRY",

   "studentPhones": [

      {

         "phoneDescription": "cell",

         "phoneNumber": "551-551-02-05"

      },

      {

         "phoneDescription": "home",

         "phoneNumber": "551-551-02-05"

      }

   ]

}

Success

XML

<?xml version="1.0" encoding="utf-8"?>

<STUDENT_DATA odata.type="String 1" xmlns:prx="urn:sap.com:proxy:AHD:/1SAI/TAS247C1D037C6F789A7507:731">

    <studentID>66s777</studentID>

    <firstName>Rıdvan</firstName>

    <lastName>Cakir</lastName>

    <timeZone>Europe/Athens</timeZone>

    <currencyID>TRY</currencyID>

    <studentPhones>

        <phoneDescription>cell</phoneDescription>

        <phoneNumber>531-551-02-05</phoneNumber>

    </studentPhones>

    <studentPhones>

        <phoneDescription>home</phoneDescription>

        <phoneNumber>551-551-22-05</phoneNumber>

    </studentPhones>

</STUDENT_DATA>

JSON

{

   "@odata.type": "#Users",

  "studentID": "66s777",

   "firstName": "Rıdvan",

   "lastName": "Cakir",

   "timeZone": "Europe/Athens",

   "currencyID": "TRY",

   "studentPhones": [

      {

         "phoneDescription": "cell",

         "phoneNumber": "531-551-02-05"

      },

      {

         "phoneDescription": "home",

         "phoneNumber": "551-551-22-05"

      }

   ]

}

Rıdvan Çakır

Accepted Solutions (1)

Accepted Solutions (1)

maheswarareddykonda
Active Contributor
0 Kudos

Hi,

here you don't need to go for java mapping or udf...you can just add those double codes("")..in mapping level for that particular field.

0 Kudos

Hi Maheswarareddy,

I've tried before. Rest Adapter double quotes "studentID": "\"66733\""


not working

maheswarareddykonda
Active Contributor
0 Kudos

the reason rest adapter is behaving like that, whatever other than string words will not add the double codes.

so please check with that SuccessFactors LMS team, if that possible to change as integer in their code level. in case they not agree to modify anything, i would suggest you to go for custom module. here is the link which already well wrote code by Eng Swee Yeoh

hasan_celebi
Participant
0 Kudos

Hi Rıdvan;

You can change the content type by these configuration parameters, probably it will work;

Module Name: AF_Modules/MessageTransformBean
Parameter Name : Transform.ContentType
Parameter Value : application/json

Best Regards
Hasan

fatihpense
Active Contributor
0 Kudos

Thanks. So the answer is:

Step1 - xml->json in Operation Mapping

Step2 - Content type "application/json" (in OM or in Adapter Module)

0 Kudos

thank you for the response Hasan,

problem solved.

This error is solved after content type changes

- 406 not acceptable Error

The rest adapter

Data Format JSON and  HTTP Headers Content Type not Changed Content Type

There are 2 ways to change it

1.) Java Mapping - setContentType

@Override

public void transform(TransformationInput in, TransformationOutput out)

throws StreamTransformationException {

out.getOutputHeader().setContentType("application/json; charset=UTF-8");

execute(in.getInputPayload().getInputStream(), out.getOutputPayload()

.getOutputStream());

}

2.) Your solution - Module

Former Member
0 Kudos

Hi Ridvan,

could you please let me know how were you able to achieve this?

I am facing same problem. I tried adding adapter module option but it didnt work? do i have to make exact change as HASAN?

would it be possible for you to let me know how was it done in detail please.

your advise is really appreciable

thanks very much

Ramesh

Former Member
0 Kudos

Hi,

You can get this resolved by applying a REST adapter patch, they have given a configuration table by which you can explicitly tell which JSON field is integer, string or array.

check this:

Regards

Ravijeet

Answers (0)