Skip to Content
0
Feb 19, 2019 at 11:50 AM

HTTP call post param in the paylod (b1if)

2038 Views Last edit Jun 11, 2019 at 12:15 PM 4 rev

Hi all,

I would like to use Http call post in b1if to request an api. but my payload is empty and i need help !

By example I want to send a param like that in the payload ----> data = {param1="X",param2="Y"} , key="kjnjjjjknjkbcmal"

Could you please explain me such a scenario with an example, how to declare param in the payload like ->

<pltype>json</pltype>
<payload>
    data = {param1="X",param2="Y"}
    key = "mkzdiazhdiaHDZDHUZADHUQ"
 </payload>

there is the picture of my postman request who work -> 200 OK

:

There is my request xml file (fb1) atom2.txt:

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:b1e="urn:com.sap.b1i.sim:b1event" xmlns:b1ie="urn:com.sap.b1i.sim:b1ievent" xmlns:b1im="urn:com.sap.b1i.sim:b1imessage" xmlns:bfa="urn:com.sap.b1i.bizprocessor:bizatoms" xmlns:jdbc="urn:com.sap.b1i.adapter:jdbcadapter" xmlns:js="com.sap.b1i.bpc_tools.Javascript" xmlns:rfc="urn:sap-com:document:sap:rfc:functions" xmlns:sim="urn:com.sap.b1i.sim:entity" xmlns:uplt="urn:com.sap.b1i.xcellerator:upltdoc" xmlns:utils2="com.sap.b1i.bpc_tools.Utilities" xmlns:vpf="urn:com.sap.b1i.vplatform:entity" xmlns:xci="urn:com.sap.b1i.xcellerator:intdoc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" bfa:force="" vpf:force="" jdbc:force="" rfc:force="" b1ie:force="" b1e:force="" xci:force="" sim:force="" utils2:force="" b1im:force="" uplt:force="" js:force=""><xsl:output method="xml" encoding="UTF-8" indent="yes"></xsl:output><xsl:param name="atom"></xsl:param><xsl:param name="sessionid"></xsl:param><xsl:variable name="msg" select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role='S']"></xsl:variable><xsl:variable name="vpSender" select="/vpf:Msg/vpf:Header/vpf:Sender/@Id"></xsl:variable><xsl:variable name="vpObject" select="/vpf:Msg/vpf:Header/vpf:Sender/@ObjId"></xsl:variable><xsl:variable name="vpReceiver" select="/vpf:Msg/vpf:Header/vpf:ReceiverList/vpf:Receiver[./@handover='P']/@Id"></xsl:variable><xsl:template match="/"><xsl:variable name="vptsDoc" select="document('/com.sap.b1i.internal/xml/timestamp')"></xsl:variable><xsl:variable name="vpts" select="concat($vptsDoc/*/@year,'/',$vptsDoc/*/@month,'/',$vptsDoc/*/@date,' ',$vptsDoc/*/@hour,':',$vptsDoc/*/@minute,':',$vptsDoc/*/@second)"></xsl:variable><vpf:Msg>
            <xsl:copy-of select="/vpf:Msg/@*"></xsl:copy-of>
            <xsl:copy-of select="/vpf:Msg/vpf:Header"></xsl:copy-of>
            <vpf:Body>
                <xsl:copy-of select="/vpf:Msg/vpf:Body/*"></xsl:copy-of>
                <vpf:Payload Role="X" id="{$atom}" ts="{$vpts}">
                    <xsl:call-template name="transform"></xsl:call-template>
                </vpf:Payload>
            </vpf:Body>
        </vpf:Msg></xsl:template><xsl:template name="transform">
        <call>
            <xsl:variable name="var1">{"id":"1","name":"kihuihu"}
            </xsl:variable>
            <connect>
                <!--the connect section is optional - you can also define a reference to the sld-->
                <destProtocol>http</destProtocol>
                <destHost>localhost</destHost>
                <destPort>8081</destPort>
                <destPath>/api/all</destPath>
                <query></query>
                <proxyHost></proxyHost>
                <proxyPort></proxyPort>
                <method>POST</method>
                <authentification>NONE</authentification>
                <user></user>
                <password></password>
                <user2query></user2query>
                <password2query></password2query>
                <trustStoreURI></trustStoreURI>
                <keyStoreURI></keyStoreURI>
                <tlsVersion></tlsVersion>
            </connect>
            <!--<query id="apikey" value="3JKKJBJH.YYV.3V3G3VG3VHG3VGH"></query><query id="data" value="{$var1}"></query>-->
            <dtd>
                <!--optional - document type definition-->
            </dtd>
            <pltype>xml</pltype>
            <payload>
               <apikey>bb3KBJ3JH3JH3JH3JH33JGV3G3VG3</apikey>
               <query id="data" value="{$var1}"></
            </payload>
            <htta>
                <par id="httpheader.Content-Type" value="application/x-www-form-urlencoded"></par>
                <par id="httpheader.Accept" value="application/json">
                    <!--optional - you can specify here your own http header definitions - multiple elements allowed-->
                </par>
                <par id="htta.returnpltypeforce" value="json">
                    <!--optional-->
                </par>
                <par id="htta.returnpltypedefault" value="json">
                    <!--optional-->
                </par>
            </htta>
        </call>undefined
    </xsl:template></xsl:stylesheet>

Attachments

download.jpeg (61.6 kB)
atom2.txt (4.3 kB)