Hey @e-deepanraj
You can use custom code but one thing you would need to understand is that in that case you would just be making use of the custom code functionality within Adobe data collection tags (launch) and not explicitly using web sdk.
You will be making use of a HTTP API Streaming endpoint which would need to be setup under sources within AEP.
Then, in your custom code, you would be using that streaming endpoint and sending a POST request to it with a payload.
Please note, I would suggest you ask your backend team to handle this rather than you doing it through launch as this can be got hold of and played with easily from Adobe Launch.
Sharing a sample JS that should work for you when you fit relevant values for your setup.
function lambdaHandler(event, context) {
const url = "<Your Streaming Endpoint URL>";
// JSON payload
const payloadData = {
header: {
schemaRef: {
id: "<Schema ID>",
contentType: "application/vnd.adobe.xed-full+json;version=1.0"
},
imsOrgId: "<YOUR ORG ID>",
datasetId: "<YOUR DATASET ID>",
source: {
name: "Streaming dataflow - 10/15/2023, 2:30 PM"
}
},
body: {
xdmMeta: {
schemaRef: {
id: "<Your Schema ID>",
contentType: "application/vnd.adobe.xed-full+json;version=1.0"
}
},
xdmEntity: {
_id: "/uri-reference",
_repo: {
createDate: "2023-12-11T12:00:00-06:00",
modifyDate: "2023-12-11T12:00:00-06:00"
},
_spnam: {
identification: {
core: {
email: '<your email>'
}
}
},
person: {
name: {
firstName: 'test league'
}
}
}
}
};
// Convert the payload to JSON
const payloadJson = JSON.stringify(payloadData);
// Headers
const headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('sandbox-name', '<Sandbox Name>');
headers.append('Authorization', 'Bearer YOUR_AUTHORIZATION_TOKEN'); // Replace with your actual Authorization token
// Request options
const options = {
method: 'POST',
headers: headers,
body: payloadJson
};
// Make the POST request
fetch(url, options)
.then(response => {
if (response.status === 200) {
return response.text();
} else {
throw new Error("Failed to call the API");
}
})
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});
}
// Example usage:
const event = {
};
lambdaHandler(event, null); I removed a few bits which were not relevant and you might need to tweak it a bit but this should give you a start.