Hi Jeeva,
In addition to the support tech note Daniel provided, GatewayScript supports the querystring module, see https://www.ibm.com/docs/en/datapower-gateway/10.0.x?topic=apis-querystring-module, and specifically the parse function of that module is of interest. Here is a simple example as shown from within the GatewayScript CLI debugger:
(debug)
1:let querystring = require('querystring');
2:let requestBody = context.get('request.body');
3:let requestBodyJSON = querystring.parse(requestBody.toString());
=>4:debugger;
(debug) p requestBody.toString()
p1=value1&p2=value%2Bwithplus
(debug) p requestBodyJSON
{ p1: 'value1', p2: 'value+withplus' }
this happens to be a v10 API Gateway example, thus the payload is retrieved with a context.get. The value for p2 also has an encoded character. The parse function returns a JSON object with the parameter names as the property keys, and the values are JSON decoded values, so what the tech note showed by doing your own parsing by splitting on the & and iterating over this list by splitting on the = and then decoding the value, you can do in a single instruction.
Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
------------------------------
Original Message:
Sent: Mon June 08, 2020 03:27 AM
From: Daniel Castellano Bonilla
Subject: Form Data to Xml transformation in API CONNWCT
Hi Jeeva.
The correct MIME type is application/x-www-form-urlencoded use it instead the one that you wrote ;-)
There is not a parser for that MIME type, so I'm afraid that it will be not as simple as drop a box in the assembly. Your question was answered on the IBM support (https://www.ibm.com/support/pages/support-web-form-api-connect-post-http-requests-applicationx-www-form-urlencoded-and-multipartform-data-content-types) a year ago, but the answer is the same; the RFE that is pointing was rejected (https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=91616).
You'll have to write a gateway script, check the code example on the IBM support page linked above.
------------------------------
Daniel Castellano Bonilla
Original Message:
Sent: Sun June 07, 2020 02:25 PM
From: Jeeva S
Subject: Form Data to Xml transformation in API CONNWCT
Hi,
I want to convert incoming payload formdata application/www-Url-encode to xml in API Connect? Can you please help me with the available option to do that?
------------------------------
Jeeva S
------------------------------