2

I'm working on to trigger API event in journey/Journey builder from landing pages. For now, I can able to get accessToken using clientId & clientSecret and then I tried to pass subscriberkey & contactkey to send email

Actual I get this code in some other thread & tried to understand/ execute:

How to fire Journey API Entry event through AMPscript?

I passing value as

var subscriberKey = "test@email.com";

var emailAddress = "test@email.com";

and I don't want to push data into any DE while triggering API event & subscriber key is not 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;
}

Getting error :

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"}

thanks in advance.

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.