2

I'm working creating a trigger API event in Journey builder from landing pages. I am currently able to get the accessToken using clientId & clientSecret, but then I tried to pass subscriberkey & contactkey to send email

I got this code from this thread & tried to understand/execute:

How to fire Journey API Entry event through AMPscript?

I am passing the value as

var subscriberKey = "test@email.com";

var emailAddress = "test@email.com";

but I don't want to push data into any DE while triggering the API event & subscriber key is not a field of DE & Email is primary key

While to call HTTP-Post of eventRequest :

{    
    var url = 'https://www.exacttargetapis.com/interaction/v1/events?access_token=' + accessToken;
    var contentType = 'application/json';
    var payload = {
        ContactKey : subscriberKey,
        //ContactKey : emailAddress,
        EventDefinitionKey : eventDefinitionKey, 
        EstablishContactKey: true,
        Data : {}
    };
   var eventRequest = HTTP.Post(url, contentType, Stringify(payload));
   if (eventRequest.StatusCode == 201) { // 201 is Created
    var requestResponse = Platform.Function.ParseJSON(eventRequest.Response[0]);
    // Write(Stringify(requestResponse)); // uncomment to see the returned object
    if (requestResponse.eventInstanceId != null && requestResponse.eventInstanceId != "") { // eventInstanceId is a GUID 
        // TODO: maybe we should check that it is actually a GUID and not some other string
        return true; // we got a GUID the event has been fired
    }
}
  return false;
}

This is the error that I'm getting:

accessTokenException Error: {"message":"Object expected: log","jintException":"Jint.Native.JsException: Exception of type 'Jint.Native.JsException' was thrown.\r\n at Jint.ExecutionVisitor.Visit(MethodCall methodCall)\r\n at Jint.Expressions.MethodCall.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(MemberExpression expression)\r\n at Jint.Expressions.MemberExpression.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(ExpressionStatement statement)\r\n at Jint.Expressions.ExpressionStatement.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(BlockStatement statement)\r\n at Jint.Expressions.BlockStatement.Accept(IJintVisitor visitor)\r\n at Jint.Native.JsFunction.Execute(ExecutionVisitor visitor, JsDictionaryObject that, JsInstance[] parameters)\r\n at Jint.ExecutionVisitor.ExecuteFunction(JsFunction function, JsDictionaryObject that, JsInstance[] parameters)\r\n at Jint.ExecutionVisitor.Visit(MethodCall methodCall)\r\n at Jint.Expressions.MethodCall.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(MemberExpression expression)\r\n at Jint.Expressions.MemberExpression.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(AssignmentExpression statement)\r\n at Jint.Expressions.AssignmentExpression.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(ExpressionStatement statement)\r\n at Jint.Expressions.ExpressionStatement.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(BlockStatement statement)\r\n at Jint.Expressions.BlockStatement.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(IfStatement statement)\r\n at Jint.Expressions.IfStatement.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(BlockStatement statement)\r\n at Jint.Expressions.BlockStatement.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(TryStatement statement)","description":"Jint.Native.JsException: Object expected: log\r\nException of type 'Jint.Native.JsException' was thrown. - from Jint\r\n\r\n"}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.