diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java index fab8e968606..703d3e58012 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java @@ -1865,7 +1865,7 @@ private void handleContentType( + ".find(key => key.toLowerCase() === 'content-type');"); writer.openBlock("if (contentTypeHeaderKey != null) {", "};", () -> { writer.write("const contentType = output.headers[contentTypeHeaderKey];"); - if (optionalContentType.isPresent() || operation.getInput().isPresent()) { + if (optionalContentType.isPresent() || HttpBindingIndex.of(context.getModel()).hasRequestBody(operation)) { String contentType = optionalContentType.orElse(getDocumentContentType()); // If the operation accepts a content type, it must be either unset or the expected value. writer.openBlock("if (contentType !== undefined && contentType !== $S) {", "};", contentType, () -> {