on 10-16-2015 9:14 AM
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.