0

In the following code, I pass in the REST url, the access token and the journeys I want it act on - in the from of an array of objects.

The issue is that the request always fails with a 404 - Object found not... However, I have yet to figured out why.

Any clue were as to why this is happening?

  function pauseJourneys(url, token, journeys){
    try{
      var endpoint = '/interaction/v1/interactions/pause/'
      var payload = {
        "ExtendWaitEndDates":false,
        "PausedDays":14,
        "ProcessWaitUntilEvents":true,
        "GuardrailAction":"Stop",
        "RetainContactInjectionWhileJourneyPaused":true
      }
      var bearerToken = "Bearer " + token
      var headers = ["Authorization"]
      var values = [bearerToken]
      
      for(var i = 0; i < journeys.length(); i++){
        var res = HTTP.Post( url + endpoint + journeys[i].definitionId + '?versionNumber=' + journeys[i].version, "application/json", Stringify(payload), headers, values)
        
        Write(Stringify(res))
      }
      
    }catch(e){
      Write(Stringify(e));
    }
  }

Postman request returns the following:

{
    "message": "Interaction matching criteria not found.",
    "errorcode": 30003,
    "documentation": ""
}
10
  • 1
    Have you tested it in Postman for a single journey definition? Apr 6, 2022 at 17:35
  • I have not tested in postman. However, I am not sure if that will help. But I will give it a shot. Apr 6, 2022 at 17:53
  • 1
    I test any REST calls in Postman first, since it's easier to iterate. Postman can also generate JS code for you, which is a good place to start for implementing it in a CloudPage or Script Activity. Apr 6, 2022 at 18:02
  • I test in postman and the response is more or less the same - as soon in the revised post. Apr 6, 2022 at 18:20
  • Which key in the interaction object should I use in this call. definitionId or id Apr 6, 2022 at 18:25

1 Answer 1

1

I'd add some debugging statements and execute it in a CloudPage:

function pauseJourneys(url, token, journeys){

  try {

    var endpoint = '/interaction/v1/interactions/pause/'
    var payload = {
      "ExtendWaitEndDates":false,
      "PausedDays":14,
      "ProcessWaitUntilEvents":true,
      "GuardrailAction":"Stop",
      "RetainContactInjectionWhileJourneyPaused":true
    }

    var bearerToken = "Bearer " + token
    var headers = ["Authorization"]
    var values = [bearerToken]
    
    for(var i = 0; i < journeys.length(); i++){

      Write("<hr>url: " + url);
      Write("<br>endpoint: " + endpoint);
      Write("<br>journeys["+i+"].definitionId: " + journeys[i].definitionId);
      Write("<br>journeys["+i+"].version: " + journeys[i].version);

      //var res = HTTP.Post( url + endpoint + journeys[i].definitionId + '?versionNumber=' + journeys[i].version, "application/json", Stringify(payload), headers, values)
      
      //Write(Stringify(res))
    }
    
  } catch(e) {
    Write("<br>e: " + Stringify(e));
  }

}

1
  • Yes, you are right. I will do that. Apr 6, 2022 at 17:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .