- 3,722,424 Users
- 2,244,304 Discussions
- 7,849,826 Comments
Forum Stats
Discussions
Categories
- Industry Applications
- 3.2K Intelligent Advisor
- Insurance
- 1.4K On-Premises Infrastructure
- 495 Analytics Software
- 41 Application Development Software
- 1.8K Cloud Platform
- 700.5K Database Software
- 17.5K Enterprise Manager
- 16 Hardware
- 248 Infrastructure Software
- 129 Integration
- 63 Security Software
JSON format issue in BPEL 12 C

Hi,
I was trying to pass translated string( xml to native json) to a JSON Rest reference created in BPEL 12c but it is failing with a 400 bad request. Have observed that JSON payload sent in the request is containing "/n" new line character and escape characters. How can we fix this?
Steps followed to reproduce this issue:
1)Create a REST reference(without choosing the WSDL interface)
2)Configure the REST bindings with JSON payload in the Request and Response
3)A native schema is created with a sample JSON ( payload to be sent to the REST reference)
4)In the BPEL, two JSON string variables are created for request/response to the REST reference
5)In the BPEL a translate activity is used to translate the input xml to the required JSON native schema and stored in a output string.
6) Assign the output string to the JSON request variable of the REST reference.
After testing the invoke is failing with the bad request having the following JSON payload:
Expected:
[ {
"keys" : {
"Id" : "Test-F37C-11e6-8508-005056B8246"
},
"values" : {
"First_Name" : "Warren",
"Middle_Name" : null,
"Last_Name" : "Buffeti",
"Title" : "MRS",
"Birthdate" : null,
"Gender" : "MALE",
"Email_Address" : "[email protected]",
"Email_Verfication_Code" : "NOT_VERIFIED",
"Mobile" : "3453466453",
"Mobile_Verfication_Code" : "NOT_VERIFIED NOT_VERIFIED",
"Email_comms_consent" : "false",
}
} ]
Actual:
[ { \n \"keys\" : {\n \"Id\" : \"Test-F37C-11e6-8508-005056B8246\" \n }, \n \"values\" : { \n \"First_Name\" : \"Warren\", \n \"Middle_Name\" : null, \n \"Last_Name\" : \"Buffeti\", \n \"Title\" : \"MRS\", \n \"Birthdate\" : null, \n \"Gender\" : \"MALE\", \n \"Email_Address\" : \"[email protected]\", \n \"Email_Verfication_Code\" : \"NOT_VERIFIED\", \n \"Mobile\" : \"3453466453\", \n \"Mobile_Verfication_Code\" : \"NOT_VERIFIED NOT_VERIFIED\", \n \"Email_comms_consent\" : \"false\", \n }}]
How to format the above json payload properly before sending to rest reference.
Thanks,
Naveen.
Answers
-
The below is working:
use JSON.parse() on the string and stored the output in a JSON object. Send the JSON object as a request to the REST reference
-
Thanks! This helps!
-
Was javascript used to implement this solution? Do you have an example? Thanks.
-
You must use the Javascript component after your transform component. Then you just add the JSON.parse() call on your JSON Object variable used in the Transform (e.g. JSON.parse(<jsonObjectVariable>);)
I ended up not even needing my Transform Component since I was receiving JSON in my request. Then I just used my Javascript component to parse what I needed in the receive payload before sending it off to the external destination.
-