Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACNA-696 - campaignStandardCoreAPI.sendTransactionalEvent does not identify event to trigger #59

Closed
DiptimanBadajena opened this issue Mar 16, 2020 · 10 comments · Fixed by #73
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@DiptimanBadajena
Copy link

DiptimanBadajena commented Mar 16, 2020

While using the Campaign Standard libraries, using sendTransactionalEvent(eventId, eventBody) does not identify the transactional event.

Expected Behaviour

sendTransactionalEvent(eventId, eventBody) library method should trigger the transactional event in Adobe Campaign Standard, resulting in message sent to target.

Actual Behaviour

sendTransactionalEvent(eventId, eventBody) library method fails to recognise the transactional event defined in Adobe Campaign Standard.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Define transactional event and related message (Email) for the event and publish.
Click on the "API preview" to fetch eventId.
For example, the transactional event published in one of the instance https://mc.adobe.io/<ORGANIZATION>/campaign/mcadobedemoinstance/EVT_Order_Approval

Nodesjs:

const acs = require('@adobe/aio-lib-campaign-standard');
const TENANT = "...";
const CLIENT_ID = "...";
const TOKEN = "...";
let payload = {"ctx":{"managerEmail": "mark.aaron@comcast.net",...}};
let eventName = "EVT_Order_Approval"
let send_mc_message = async function (tenant, client_id, token, eventName, payload) {
    let acs_instance = await acs.init(tenant, client_id, token);
    return await acs_instance.sendTransactionalEvent(eventName, payload);
};

Error message:

{ CampaignStandardSDKError: [CampaignStandardSDK:ERROR_SEND_TRANSACTIONAL_EVENT] 404 - Not Found ("RST-360011 An error has occurred - please contact your administrator. Error rc=-2003")
    at new <anonymous> (/Users/diptimanbadajena/Documents/Assignments/2020-21/Accelerators/AIO-CNA/cna-app3/node_modules/@adobe/aio-lib-core-errors/src/AioCoreSDKErrorWrapper.js:33:9)
    at sdk.apis.messaging.sendTransactionalEvent.then.catch.err (/Users/diptimanbadajena/Documents/Assignments/2020-21/Accelerators/AIO-CNA/cna-app3/node_modules/@adobe/aio-lib-campaign-standard/src/index.js:428:18)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  code: 'ERROR_SEND_TRANSACTIONAL_EVENT',
  sdk: 'CampaignStandardSDK',
  sdkDetails:
   { eventId: 'EVT_DMKT_Order_Approval',
     eventBody: { ctx: [Object] } },
  name: 'CampaignStandardSDKError' }

Platform and Version

aio -v
@adobe/aio-cli/2.3.0 darwin-x64 node-v10.16.0

Sample Code that illustrates the problem

Logs taken while reproducing problem

@meryllblanchet
Copy link
Contributor

meryllblanchet commented Mar 18, 2020

Hi @DiptimanBadajena ,

Thank you for raising the issue. Could I ask you to confirm wether you experience the same behavior by cURLing the API directly or not?

Note aside: you could update the CLI to its latest 3.1.0 version (npm install -g @adobe/aio-cli)

cc @shazron

@shazron
Copy link
Member

shazron commented Mar 19, 2020

Hi, in addition to the curl verification, can you also send the (sanitized) logs via these instructions below? I'm particularly interested in the REQUEST call that was sent. https://github.com/adobe/aio-lib-campaign-standard#debug-logs

@DiptimanBadajena
Copy link
Author

Hi @DiptimanBadajena ,

Thank you for raising the issue. Could I ask you to confirm wether you experience the same behavior by cURLing the API directly or not?

Note aside: you could update the CLI to its latest 3.1.0 version (npm install -g @adobe/aio-cli)

cc @shazron

Hello Meryll & Shazron,
Sorry for the delay in response. As of now the alternative approach is request using the api endpoint, which works well. About the logs, all that I have is mentioned above. Before using the libraries I usually test in nodejs native CLI and all that I have is included.

@meryllblanchet
Copy link
Contributor

Thanks for the update @DiptimanBadajena. We'll then have a deeper look at the SDK on our side and debug the function.
In case some additional information is needed, @shazron will ping you directly.

@meryllblanchet meryllblanchet added bug Something isn't working documentation Improvements or additions to documentation labels Mar 24, 2020
@shazron shazron changed the title campaignStandardCoreAPI.sendTransactionalEvent does not identify event to trigger ACNA-696 - campaignStandardCoreAPI.sendTransactionalEvent does not identify event to trigger Jun 11, 2020
@ashish84120
Copy link

ashish84120 commented Aug 7, 2020

I have run into same issue however i realized that in my case transactionalAPi value is not exactly /mc<ORGANIZATION>. Now below spec from api.json file line(493) expects the transactionalAPI value to be mc{organization} and thats why it is giving this error.
"/mc{ORGANIZATION}/{EVENT_ID}/{EVENT_PKEY}": {

In above example we will receive the error if the organization/tenant is provided as anything else than 'adobedemoinstance'
https://mc.adobe.io/{ORGANIZATION}/campaign/mcadobedemoinstance/EVT_Order_Approval

One workaround could be passing a separate parameter orgId which can be different that organization or same based on tenant setup. Below changes triggers the event successfully for me.

sendTransactionalEvent (eventId, orgId, eventBody) {
const sdkDetails = { eventId, orgId, eventBody }

return new Promise((resolve, reject) => {
  this.sdk.apis.messaging.sendTransactionalEvent(
    {
      ORGANIZATION: orgid,
      EVENT_ID: eventId
    }, this.__createRequestOptions({ body: eventBody }))
    .then(response => {
      resolve(response)
    })
    .catch(err => {
      reject(new codes.ERROR_SEND_TRANSACTIONAL_EVENT({ sdkDetails, messageValues: reduceError(err) }))
    })
})

}

@shazron
Copy link
Member

shazron commented Aug 17, 2020

@ashish84120 I'm not sure I follow. The spec at https://docs.adobe.com/content/help/en/campaign-standard/using/working-with-apis/managing-transactional-messages.html says that the endpoint is essentially the form of:

POST https://mc.adobe.io/<ORGANIZATION>/campaign/mc<ORGANIZATION>/<eventID>

orgId which can be different that organization or same based on tenant setup

Is there something in the docs regarding this?

@shazron
Copy link
Member

shazron commented Aug 20, 2020

I'm confirming with someone on the Campaign Standard team regarding the usage vs the docs.

But based on what I've seen so far (pending the Campaign Standard team's confirmation), we will deprecate the existing function:
sendTransactionalEvent(eventId, eventBody)
and have a new function:
sendTransactionalEventForOrg (orgId, eventId, eventBody)

@shazron
Copy link
Member

shazron commented Aug 23, 2020

PR #73

@shazron
Copy link
Member

shazron commented Aug 23, 2020

@meryllblanchet I think getTransactionalEvent might have the same problem and may require the same type of fix, since it has the same URL format with a mc prefix for the tenant id. I didn't change it here, it should be a separate issue and fix.

@meryllblanchet
Copy link
Contributor

Good point @shazron, I'll create a separate issue and assign to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
4 participants