1

I am running into a strange problem and hope someone can help me to solve it. In my .NET code I making a REST API call to get a publish status after calling publishAsync, which returns a statusId. I then specify the statusId to get the status of the publish in the publishStatus REST call. For some reason I am getting 404 Not Found error code. I am not sure why I would get this error, I am following the API documentation and providing the correct endpoint URL. Here are the URLs from API call to publishAsync that returns statusUrl and StatusId and from publishStatus API call request.

Returned from publishAsync;

{
  "statusUrl": "/interaction/v1/interactions/publishStatus/128c362a-3a9c-4a56-bfb9-5fe5e0ab303b",
  "statusId": "128c362a-3a9c-4a56-bfb9-5fe5e0ab303b"
}

publishStatus request url:

https://www.exacttargetapis.com/interaction/v1/interactions/publishStatus/128c362a-3a9c-4a56-bfb9-5fe5e0ab303b

.NET C# code:

public async static Task<JToken> GetPublishStatusAsync(string statusId, string accessToken, CancellationToken ct)
{
    if (string.IsNullOrEmpty(statusId))
        throw new ArgumentNullException(nameof(statusId), ErrorCode.FailedToGetPublishStatus.GetDescription());

    if (string.IsNullOrEmpty(accessToken))
        throw new ArgumentNullException(nameof(accessToken), ErrorCode.FailedToGetPublishStatus.GetDescription());

    using (var handler = new HttpClientHandler())
    {
        handler.Proxy = WebRequest.DefaultWebProxy;
        handler.Credentials = CredentialCache.DefaultCredentials;
        handler.Proxy.Credentials = CredentialCache.DefaultCredentials;
        using (var client = new HttpClient(handler))
        {
            var query = string.Format("/{0}", WebUtility.UrlEncode(statusId));
            var req = new HttpRequestMessage()
            {
                RequestUri = new Uri(EndpointUrl + "/publishStatus" + query),
                Method = HttpMethod.Post
            };
            req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
            req.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            ct.ThrowIfCancellationRequested();
            using (var res = await client.SendAsync(req))
            {
                var json = JToken.Parse(await res.Content.ReadAsStringAsync());
                if (res.IsSuccessStatusCode)
                    return json;
                else
                {
                    var ex = new Exception(ErrorCode.FailedToGetPublishStatus.GetDescription());
                    ex.Data.Add("Status ID", statusId);
                    ex.Data.Add(nameof(res.StatusCode), res.StatusCode);
                    ex.Data.Add("Message", json.Value<string>("message"));
                    ex.Data.Add("Errorcode", json.Value<string>("errorcode"));
                    ex.Data.Add("Headers", res.Headers.ToJsonString());
                    throw ex;
                }
            }
        }
    }
}

By the way, the publishAsync call doesn't publish the Journey after all so I am not sure what is going on and which part is failing when the two calls are unsuccessful. I hope someone can shed some light on this.

  • This is working for me (I can publish a journey using publishAsync and retrieve publishStatus from the URL in the response payload). Please can you confirm what endpoint you are using for publishAsync and confirm you are appending the version number to this URL, e.g. ?versionNumber=1 – Eliot Harper Apr 3 '17 at 6:11
  • 1) Hi Adam and thanks for the response. the endpoint is this: exacttargetapis.com/interaction/v1/interactions/publishAsync/… And the response is this: { "statusUrl": "/interaction/v1/interactions/publishStatus/62055a94-cb39-425e-9477-882d7258bddf", "statusId": "62055a94-cb39-425e-9477-882d7258bddf" } – A.G. Apr 3 '17 at 15:39
  • 2) As you can see I am getting successful response from publishAsync call with statusId and statusUrl. What I think is going on is that the publishAsync fails after sending a response and statusId is not bing saved in the system therefor statusId is not found by publishStatus. – A.G. Apr 3 '17 at 15:42
  • 3) What I noticed is that when I try to publish a journey which has 'Stopped" status it fails with 404 not found error code and actually it changes the status of the journey to 'Draft' :( – A.G. Apr 3 '17 at 16:29
  • Ok, I was actually using POST method instead of GET that is why I was getting 404. Now I am getting an error response but it does not specify why it error out. The response returned is this: { "status": "Error", "errors": [] }. How can I find out what went wrong? – A.G. Apr 3 '17 at 17:06
0

As you indicated in your comment, the reason you are getting a 404 error is that you need to make a GET request to the publishStatus method.

Regarding your other issue:

Now I am getting an error response but it does not specify why it error out. The response returned is this: { "status": "Error", "errors": [] }. How can I find out what went wrong?

Firstly, I would try and publish the Journey from the Journey Builder interface to see if you get any error information back. Given that you get an empty errors array in your API response, you probably won't get any additional message, but it's worth a try.

The only time I've seen an empty error message is when I have one or more Send Email activities in my Journey and the email is missing. For example, the actual email has been deleted before the Journey is published. Open each Send Email Activity in Journey Builder and check that the email actually exists.

| improve this answer | |
  • Hi Eliot, thanks for your response. I tried your suggestion publishing from Journey Builder and yes I get errors. What I am tiring to achieve is to copy a Journey from one environment to another with my app and let the user to publish it. It seems that some activity configurations need to be setup in the new environment before it can be published. I am getting two groups of errors: 'This activity must be configured before activation can be successful.' and 'Failed to load custom activity configuration file.' – A.G. Apr 6 '17 at 17:43
  • It works with journeys have all activity configs set up on the server. Thanks for all your help. – A.G. Apr 6 '17 at 18:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.