Solved
AEP Integration with Node JS Using SDK breaking
Hi Team,
We are trying to use AIO SDK to connect to AEP from our node JS application but the library is throwing an error.
SDK Reference: https://github.com/adobe/aio-lib-customer-profile/blob/master/README.md
Code Snippet:
const http = require('http');
const sdk = require('@adobe/aio-lib-customer-profile');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
async function sdkTest() {
//initialize SDK - I have provided correct value in code - this is just for reference
const client = await sdk.init('<tenant>', '<iMSOrgId>', 'x-api-key', '<valid auth token>', '[sandbox]')
const profileParams = {
entityId: '079157043',
entityIdNS: 'loyaltyId'
}
const customerProfile = await client.getProfile(profileParams)
}
sdkTest();
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});Error:
/Users/xyz/node/node_modules/@adobe/aio-lib-core-errors/src/AioCoreSDKErrorWrapper.js:33
super(util.format(message, ...messageValues), code, sdkName, sdkDetails)
^
AioCoreSDKError [CustomerProfileAPIError]: [CustomerProfileAPISDK:ERROR_ENTITIES] Error TypeError: Failed to parse URL from /data/core/ups/access/entities?schema.name=_xdm.context.profile&entityId=079157043&entityIdNS=loyaltyId
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async http (/Users/xyz/node/node_modules/swagger-client/lib/http/index.js:74:11) {
[cause]: TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:405:5)
at new URL (node:internal/url:778:13)
at new Request (node:internal/deps/undici/undici:7132:25)
at fetch2 (node:internal/deps/undici/undici:10715:25)
at Object.fetch (node:internal/deps/undici/undici:11574:18)
at fetch (node:internal/process/pre_execution:271:25)
at http (/Users/xyz/node/node_modules/swagger-client/lib/http/index.js:74:45)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
input: '/data/core/ups/access/entities?schema.name=_xdm.context.profile&entityId=079157043&entityIdNS=loyaltyId',
code: 'ERR_INVALID_URL'
}
}
at new <anonymous> (/Users/xyz/node/node_modules/@adobe/aio-lib-core-errors/src/AioCoreSDKErrorWrapper.js:33:9)
at /Users/xyz/node/node_modules/@adobe/aio-lib-customer-profile/src/openApiSDK.js:102:18
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERROR_ENTITIES',
sdk: 'CustomerProfileAPISDK',
sdkDetails: { parameters: { entityId: '079157043', entityIdNS: 'loyaltyId' } }
}
Any idea what is wrong here? From my observation, it looks like the host is missing https://platform.adobe.io.
Any idea what is wrong here? From my observation, it looks like the host is missing https://platform.adobe.io.
