DataPower

 View Only
Expand all | Collapse all

Inserting Username and Password In MIME parts before making a backend call from Data power

  • 1.  Inserting Username and Password In MIME parts before making a backend call from Data power

    Posted Tue April 05, 2022 07:11 PM
    Hello Herman and Team
    We are receiving mime multipart request from consumer. Before we forward the same request to backend, we would need to add username and password values in mime parts as you see in below MIME parts sample. Does anyone know how we can  achieve this in data power? 


    2007-08-30
    ------=_Part_10_392539974.1637162494218
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    Content-Disposition: form-data; name="UserName"

    username

    ------=_Part_10_392539974.1637162494218
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    Content-Disposition: form-data; name="Password"

    password


    ------------------------------
    sridhar kanaparti
    ------------------------------


  • 2.  RE: Inserting Username and Password In MIME parts before making a backend call from Data power

    IBM Champion
    Posted Wed April 06, 2022 09:18 AM
    I'm saying this without even remotely trying it, but, my first attack would be to process it with GatewayScript.

    ------------------------------
    Joseph Morgan
    ------------------------------



  • 3.  RE: Inserting Username and Password In MIME parts before making a backend call from Data power

    IBM Champion
    Posted Sat April 09, 2022 06:25 AM
    Hi,

    there are few ways to approach this. The easiest option might be to split the multipart using "Convert query params to XML" action and then reassembling the multipart with additional parts using wither GWScript or XSLT. The caveat of this approach is that you have to make sure the end result of "Convert query params" action will be valid XML. Otherwise the processing will fail.  

    The second more complex option is to convert the multipart/form-data to multipart/related (for example using HermannSW's Content-Disposition rewrite) and then let DataPower to automatically parse the parts as attachments. Then you can add the additional parts as new attachments by using for example Results action and attachment:// protocol. DataPower then compiles the new extended multipart message automatically. This option is more viable if you need to handle large binary attachments (PDFs, images, etc.). The caveat is the fact that you need to change the multipart/form-data to multipart/related and vice-versa if you don't have the option to send the multipart/related all the way through. And you need to have XML in the first part of the message to get DP to pare the attachments correctly.

    The third option might be to use GWScript like Joseph suggested and apply some buffers "magic" to it like HermannSW describes in https://www.ibm.com/mysupport/s/question/0D50z00006AB79LCAT/how-to-addinject-a-key-value-pair-to-an-incoming-form-data-using-gateway-script?language=en_US

    Hope you are able to solve your problem.



    ------------------------------
    Hermanni Pernaa
    ------------------------------