cancel
Showing results for 
Search instead for 
Did you mean: 

Hybris Marketing Landing Page Integration

swallis
Participant
0 Kudos

Hi,

I'm currently coding the integration for a Hybris Marketing Landing Page so we can add it to our Web server. I'm using .Net and have coded based on the PHP example provided in the documentation. However, when running the service an error occurs after the POST request, in the JavaScript file generated by Hybris for the following line of code:

var m = JSON.parse(h.responseText)

the response data I'm getting back from the oData service is XML - e.g.

<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="https://<env>:443/sap/opu/odata/sap/CUAN_CONTENT_PAGE_RESULT_SRV/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
    <id>https://<env>:443/sap/opu/odata/sap/CUAN_CONTENT_PAGE_RESULT_SRV/ResultHeaders('')</id>
    <title type="text">ResultHeaders('')</title>
    <updated>2018-01-03T15:12:18Z</updated>
    <category term="CUAN_CONTENT_PAGE_RESULT_SRV.ResultHeader" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
    <link href="ResultHeaders('')" rel="self" title="ResultHeader"/>
    <link href="ResultHeaders('')/ResultValues" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ResultValues" type="application/atom+xml;type=feed" title="ResultValues"/>
    <link href="ResultHeaders('')/ContactPersonalizationData" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ContactPersonalizationData" type="application/atom+xml;type=feed" title="ContactPersonalizationData"/>
    <link href="ResultHeaders('')/ContactFacets" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ContactFacets" type="application/atom+xml;type=feed" title="ContactFacets"/>
    <link href="ResultHeaders('')/Answers" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Answers" type="application/atom+xml;type=feed" title="Answers"/>
    <content type="application/xml">
        <m:properties>
            <d:Id/>
            <d:ContentPageKeyHash>ABC123</d:ContentPageKeyHash>
            <d:Url>myurl</d:Url>
            <d:IpAddress/>
            <d:OutboundId/>
            <d:ResultEvent>OPEN</d:ResultEvent>
            <d:SessionId/>
            <d:FollowUpPage/>
            <d:ProductiveTestMode>false</d:ProductiveTestMode>
            <d:CampaignId/>
        </m:properties>
    </content>
</entry>

Should the service be returning XML? If so, why is the JS file generated by Hybris is performing JSON.parse on the response data? Currently unsure why the issue is happening - any pointers would be appreciated.

Thanks

Simon

Accepted Solutions (1)

Accepted Solutions (1)

swallis
Participant

Turns out I wasn't setting the Accept: application/json header in the request

Answers (0)