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.
publishAsync
and confirm you are appending the version number to this URL, e.g.?versionNumber=1