DataPower

 View Only
  • 1.  Process multipart/form-data in DataPower gateway

    Posted Thu May 30, 2024 06:06 AM

    Dears,

    We have a requirement to process the multipart form data to the backend server. 

    MPGW has configured, Request Type --> JSON and Response Type --> Non-XML.

    When the DataPower receives multipart request, it is throwing an error "Invalid JSON format", Since, MPGW Request Type is set to JSON.

    Is there any way to process the request without changing the Request Type from JSON to non-XML? Because, we have different existing services impacting with the request type non-XML.



    ------------------------------
    Mahender Batta
    ------------------------------


  • 2.  RE: Process multipart/form-data in DataPower gateway

    Posted Fri May 31, 2024 06:01 AM

    Hi Mahender,
    If you're wanting to process different data types, JSON and multipart form, in the same MPGW, then you have no choice than to specify Non-XML as your request type.  However, you can specify, using the object view of your request rule, that the rule should handle non-XML data by enabling the "Non-XML Processing" option.  When the default of this option is specified (disabled), your processing rule cannot see what is in the INPUT context unless used by a binary action such as a GatewayScript action or a Convert Query Params to XML action, but enabling this option will allow this content to be available for any action.  Also note that specifying a type of JSON will cause an implicit parse of your incoming request payload with the result being JSONx in the __JSONASJSONX context.  Since that won't happen by default for type Non-XML, you can do that yourself by using a Convert Query Params to XML action using a input conversion map reference that specifies JSON encoding where the output context of the action is __JSONASJSONX . 

    If you're wanting to handle both content types in the same processing rule, you will also need to be using conditional actions looking at the content type request header to optionally do this only for application/json content.  This would require either an xsl or GatewayScript action prior to the conditional that would examine the content-type header and output  XML, for example, <isJSON>true</isJSON> which the conditional action would consume as input where your condition xpath would be /isJSON = true or != true depending upon what you wish to do.  Of course the conditional processing wouldn't be needed if you could isolate your multipart processing based on the inbound url for example where those requests could have their own request rule, which would allow your existing request rule to stay the same except for the Convert Query Params to XML action at the beginning, and the multistep handling rule could be a rule of its own.

    Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 3.  RE: Process multipart/form-data in DataPower gateway

    IBM Champion
    Posted 22 days ago

    Adding to Steve's suggestions that you can also select the correct rule based on incoming HTTP Content-Type header value and then process the payload accordingly.



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