public virtual HttpResponseMessage Delete([FromUri] string serviceName, [FromUri] Guid id, [FromUri] string phaseName, [MatrixParameter] string[] zone = null, [MatrixParameter] string[] context = null) { string sessionToken = CheckAuthorisation(serviceName, zone, context, new Right(RightType.UPDATE, RightValue.APPROVED)); preventPagingHeaders(); string body = Request.Content.ReadAsStringAsync().Result; try { IFunctionalService service = getService(serviceName); if (SettingsManager.ProviderSettings.JobBinding && !service.IsBound(id, getOwnerId(sessionToken))) { throw new InvalidSessionException("Request failed as the job referred to in this request does not belong to this consumer."); } return(OKResult(service.DeleteToPhase(id, phaseName, body, zone: (zone == null ? null : zone[0]), context: (context == null ? null : context[0]), contentType: HttpUtils.GetContentType(Request), accept: HttpUtils.GetAccept(Request)))); } catch (ArgumentException e) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid argument: id=" + id + ", phaseName=" + phaseName + ".\n" + e.Message)); } catch (DeleteException e) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Problem deleting data for " + phaseName + "@" + id + ".\n", e)); } catch (RejectedException e) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Problem deleting data for " + phaseName + "@" + id + ".\n", e)); } catch (Exception e) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Request failed for phase " + phaseName + " in job " + id + ".\n " + e.Message)); } }