Skip to Content

B1i HTTP Post request empty when Payload JSON

Dear experts:

I have the following HTTP call that actually makes it to the target system but without the payload, eventually returning that a required parameter is missing. If I set the pltype to xml then it does send the payload, but of course it's not understood by the target system. I have also tried text but is also preventing the payload from being sent.

Any idea what I'm missing here to send a JSON POST request with the payload?

Thanks in advance,

Joerg.

Capture.PNG (22.9 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jun 09, 2015 at 06:50 AM

    Hi Joerg,

    you can use the tag <query> to handover URL parameters (see extract from HTTP call atom online help):

    query id

    Enter query strings for your call.

    If you want to handover URL parameters containing special characters, you must URL encode the string. The integration framework provides the encode Java function in the utils2 namespace. To ensure that the function works correctly, cast the string with the string XPath function.

    Define the call as follows:

    <call>

    <xsl:variable name="var">{"myPar":"myVal"}</xsl:variable>

    <query id="json" value="{utils2:encode(string($var))}"/>

    ...

    </call>


    Conversions from XML towards JSON can be automized by using the specific conversion atom (please compare to online help searching by "JSON"):

    In HTTP inbound and outbound, set the payload type to JSON (pltype="jso") or (pltype="json") to receive or hand over a message payload in JSON format. In the inbound phase, the integration framework recognizes the JSON format and converts it to XML. In the outbound phase, the integration framework automatically provides the payload in JSON format.

    If you need a JSON representation in the processing phase, use the Conversion XML to JSON atom.

    You can find the file with the required schema definition in the BizStore in following place: com.sap.b1i.system/xsd/json_pltype.xsd

    You can start with an object using option 1, or with an array, using option 2.

    <!-- option 1 - starting in the root with an object-->

    <io xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:com.sap.b1i.bizprocessor:bizatoms" pltype="json"

    xsi:schemaLocation="urn:com.sap.b1i.bizprocessor:bizatoms
    json_pltype.xsd">

    <object>

    <!-- optional multiple of the following elements-->

    <string name="">value</string>

    <number name="">value</number>

    <object name="">...</object>

    <array>...</array>

    <bool name="">true/false</bool>

    <null name="" />

    </object>

    </io>

    <!-- option 2 - starting in the root with an array-->

    <io xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:com.sap.b1i.bizprocessor:bizatoms" pltype="jso"

    xsi:schemaLocation="urn:com.sap.b1i.bizprocessor:bizatoms
    json_pltype.xsd">

    <array>

    <!-- optional multiple of the following elements-->

    <string name="">value</string>

    <number name="">value</number>

    <object name="">...</object>

    <array>...</array>

    <bool name="">true/false</bool>

    <null name="" />

    </array>

    </io>

    Best regards

    Bastian

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 13, 2015 at 01:27 PM

    Nice Joerg, Bastian,

    maybe this is another solution:

    <pltype>json</pltype>

    <payload>

    <bfa:io>

    <bfa:object>

    <bfa:array name="Products">

    <bfa:object name="Product">

    <bfa:string name="Title">Title1</bfa:string>

    <bfa:string name="Price">5.0</bfa:string>

    </bfa:object>

    <bfa:object name="Product">

    <bfa:string name="Title">Title2</bfa:string>

    <bfa:string name="Price">6.0</bfa:string>

    </bfa:object>

    </bfa:array>

    <bfa:string name="Customer">Customer</bfa:string>

    <bfa:string name="City">City</bfa:string>

    </bfa:object>

    </bfa:io>

    </payload>

    <htta>

    <par id="httpheader.Content-Type" value="application/json"/>

    ...

    </htta>

    Jan

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.