0

Running into this invalid JSON error when I try to use my decision model to send offer data to be used in the experience. I've tested the decision model in test canvas and see that the offer is returned as an output of decisionModelResultNodes. I then copy this "kitchen-sink" freemarker snippet into the API tab that I found in the CDP tool that is recommended for capturing decision offers:

{
  <#if (decisionModelResults)??>
  "decisionValues": [
    <#if (decisionModelResults.decisionModelResultNodes)??>
    <#list decisionModelResults.decisionModelResultNodes as result>
    <#if (result.outputs)??>
    <#list result.outputs as output>
    <#list output as outputName, outputValue>
    <#if (!outputValue?is_hash) && outputName != "ruleId">
    {
    "decisionType": "${result.type}",
    "trackingUrl" : "${createContentTrackingURL('myContentID')}",
    "decisionName" : "${result.name}",
    "outputName" : "${outputName}",
    "outputValue" : "${outputValue}"
    }<#if output_has_next>,</#if>
    </#if>
    </#list>
    </#list>
    <#if result_has_next>
    <#if decisionModelResults.decisionModelResultNodes[result?index + 1].outputs?size != 0>,</#if>
    </#if>
    </#if>
    </#list>
    </#if>
  ],
  </#if>
  <#if (offers)??>
  "decisionOffers": ${toJSON(offers)},
  </#if>
  "guest": {}
}

With this, I get API response must be valid JSON error, but the response they show me looks like valid JSON, and the decision model returns an offer in the test canvas so I'm not sure what I can do.

1 Answer 1

0

Have you connected your decision model to your Full Stack Experience? Can you see the decision model in the data selector?

Example of the data selector is shown here: https://doc.sitecore.com/cdp/en/users/sitecore-personalize/use-dynamic-decision-model-data-in-the-api-response-for-an-interactive-experiment-718162.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.