diff options
Diffstat (limited to 'aws/aws-sdk-php/src/Api/Serializer/RestJsonSerializer.php')
-rw-r--r-- | aws/aws-sdk-php/src/Api/Serializer/RestJsonSerializer.php | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/aws/aws-sdk-php/src/Api/Serializer/RestJsonSerializer.php b/aws/aws-sdk-php/src/Api/Serializer/RestJsonSerializer.php index acc59638..8a2aa993 100644 --- a/aws/aws-sdk-php/src/Api/Serializer/RestJsonSerializer.php +++ b/aws/aws-sdk-php/src/Api/Serializer/RestJsonSerializer.php @@ -27,13 +27,16 @@ class RestJsonSerializer extends RestSerializer JsonBody $jsonFormatter = null ) { parent::__construct($api, $endpoint); - $this->contentType = 'application/json'; + $this->contentType = JsonBody::getContentType($api); $this->jsonFormatter = $jsonFormatter ?: new JsonBody($api); } protected function payload(StructureShape $member, array $value, array &$opts) { + $body = isset($value) ? + ((string) $this->jsonFormatter->build($member, $value)) + : "{}"; $opts['headers']['Content-Type'] = $this->contentType; - $opts['body'] = (string) $this->jsonFormatter->build($member, $value); + $opts['body'] = $body; } } |