in packages/service-library/src/web-api/api-controller.ts [43:69]
protected validateContentType(): boolean {
if (this.context.req.method !== 'POST' && this.context.req.method !== 'PUT') {
return true;
}
if (!this.hasPayload()) {
this.context.res = {
status: 204, // No Content
};
return false;
}
if (this.context.req.headers === undefined || this.context.req.headers['content-type'] === undefined) {
this.context.res = HttpResponse.getErrorResponse(WebApiErrorCodes.missingContentTypeHeader);
return false;
}
if (this.context.req.headers['content-type'] !== 'application/json') {
this.context.res = HttpResponse.getErrorResponse(WebApiErrorCodes.unsupportedContentType);
return false;
}
return true;
}