How can I merge 2 or more json results

I think the JSON for the request could be build with the data you have, but the authorization will be a problem.

In the input data of the API Action you can put all the root properties and they can have dynamic data, so the basketItems result can be applied there. Setting the Data Type to JSON would then generate the required JSON request.

The authorization requires a hash with the whole request in it, this can be a special PKI string or the stringified JSON from what I understand. Generating this will be a challenge and I don’t think this is possible with the current actions and formatters in Server Connect.

You use PHP, that is relative simple to edit and extend. You could add your own formatters. Add an extra file in dmxConnectLib/lib/formatters. The name of the file doesn’t matter, call it custom.php or so.

<?php

namespace lib\core;

// formatter merge
function formatter_merge($val, $data) {
    return array_merge((array)$value, (array)$data);
}

// formatter generateHash
function formatter_generateHash($val) {
    return base64_encode(sha1($val, true));
}

Formatters are called like {{ query1.merge(query2) }} and {{ apiKey + randomString + secretKey + pkiString ).generateHash() }}.

6 Likes