on 2018 May 23 7:30 PM
I work on a SAPUI5 application (in Web IDE) which creates an interaction in Hybris Marketing. Therefore I use OData service CUAN_IMPORT_SRV. I already tried it with a simple Postman request and it worked fine. The interaction was created in Hybris Marketing.
The example JSON body for upload looks like this (oriented by Call OData Service😞
{
"Id" : "",
"Timestamp" : "/Date(1506014140593)/",
"UserName" : "UNAME",
"SourceSystemId" : "ANY",
"Interactions" : [
{
"Key" : "",
"CampaignId" : "",
"CommunicationMedium" : "BUSINESS_DOCUMENT",
"ContactId" : "005056966DBE1EE4B299CD12B99F60C4",
"ContactIdOrigin" : "SAP_HYBRIS_MKT_IC",
"ContentData" : "First Event",
"ContentTitle" : "",
"InitiativeId" : "100001622",
"InitiativeVersion" : 0,
"InteractionType" : "CRM_ACTIVITY",
"IsAnonymous" : false,
"MarketingOrchestrationId" : 0,
"Quantifier" : 1,
"Timestamp" : "/Date(1506014140283)/"
}
]
}
It shall not be discussed if the data makes sense or not. It's right now just a test case. In my SAPUI5 application I started writing a simple function which shall handle the data upload. I oriented on this topic.
This is my function:
onPressScan: function() {
sap.ndc.BarcodeScanner.scan(
function(mResult) {
if (!mResult.cancelled) {
// begin POST Interaction with OData
var oModel = new sap.ui.model.odata.v2.ODataModel("https://host:port/sap/opu/odata/sap/CUAN_IMPORT_SRV/", true, "UNAME", "PASSWORD");
oModel.setHeaders({
"X-CSRF-Token" : "Fetch"
});
var jsonString = '{ "Id" : "", "Timestamp" : "/Date(1506014140591)/", "UserName" : "UNAME", "SourceSystemId" : "ANY", "Interactions" : [ ' +
'{ "Key" : "" , "CampaignId" : "" , "CommunicationMedium" : "BUSINESS_DOCUMENT" , "ContactId" : "005056966DBE1EE4B299CD12B99F60D4" ' +
', "ContactIdOrigin" : "SAP_HYBRIS_MKT_IC" , "ContentData" : "Try from Scanner App", "ContentTitle" : "Scan", "InitiativeId" : "100001622" ' +
', "InitiativeVersion" : 0, "InteractionType" : "CRM_ACTIVITY", "IsAnonymous" : false, "MarketingOrchestrationId" : 0, "Quantifier" : 1, "Timestamp" : "/Date(1506014140281)/" }]}';
var json = JSON.parse(jsonString);
// get X-CSRF-Token for POST request
oModel.read("/$metadata", null, null, true, function(oData, oResponse) {
var xcsrfToken = oResponse.headers["x-csrf-token"];
oModel.setHeaders({
"X-CSRF-Token" : xcsrfToken,
"Content-Type" : "application/json"
});
// POST interaction to yMarketing
oModel.create("/ImportHeaders", json, null, function() {
alert("Create successful");
}, function(){
alert("Create failed");
});
}, function() {
alert("Read failed");
});
}}, function(Error) {
sap.m.MessageBox.error("Scanning failed due to following error: " + Error, {
title: "Error while scanning"
});
}
);
}
When I try the application I get the following error:
What do I do wrong? I guess I can't fetch the X-CSRF-Token like I'm trying to do it. I could not find any topics on doing that with OData Model.
Thanks for every hint and your advice.
Request clarification before answering.
I could solve my problem. It didn't work because I just added this after target path of Chrome:
--disable-web-security
When I added this instead:
--disable-web-security --user-data-dir
...I could finally create an interaction in yMarketing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Concering this topic, I read some other posts and tried to edit the URL to
proxy/https/host:port/sap/opu/odata/sap/CUAN_IMPORT_SRV/
...but this results in 404 Not Found.
Since I use Chrome as Browser, I disabled web security as I read in other posts. This did not work. That's why I tried this Chrome AddOn. As a result, I got this error log:
What more can I try to solve this issue? Thank you for any advice!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
52 | |
6 | |
5 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.