Page 1 of 1

Return is formatted as urlencoded

Posted: Fri May 19, 2017 8:48 am
by thomas.carroll
the return we are receiving is not in a format that is supported by default. Do you have any recommendations to pull information from it? i am using the itmgrs log in.

below is an example of a return we are receiving.

UMversion=2.9&UMstatus=Approved&UMauthCode=018000&UMrefNum=1544346229&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=0&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=76&UMbatchRefNum=45567481&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=387138680300913&UMcardLevelResult=B%20&UMauthAmount=&UMfiller=filled

Re: Return is formatted as urlencoded

Posted: Fri May 19, 2017 9:35 am
by support
For the REST module, we support the following return types: JSON, CSV, XML, TEXT, or EMPTY

We advise you reformat your webservice return to be more easily parseable by Fuse+, the easiest being JSON.

Re: Return is formatted as urlencoded

Posted: Mon Jul 03, 2017 6:55 pm
by anorman728
I came across a similar issue with a service that I don't actually have any control over. JSON is definitely best, if possible, but, if not, I got around this by setting the return type to TEXT and using this JS function to extract the values:

Code: Select all

function parseUrl(inputUrl)
​{
​    var returnJson = {};
​    var urlArray = inputUrl.split('&');
​    var len = urlArray.length;
​    for (var i = 0; i < len; i++) {
​        dumArr = urlArray[i].split('=');
​        returnJson[dumArr[0]] = decodeURIComponent(dumArr[1]);
​    }
​    return returnJson;
​}
Run the values returned through parseUrl using the (+) button in the lower-right corner of the module (in the same module in which the function is defined) and you'll be able to set values using the same (+) button. A little bit of a pain (because editing JS in the module is a little difficult), but it does the job.