Problem description
OSS returns an error when the callbackBodyType field in the callback parameter contains a value that is not a string.
Causes
The callback parameter in an upload request is Base64-encoded. After decoding, the result is a JSON object. OSS validates each field in that JSON object, and callbackBodyType must be a string. If the value is any other type — such as a number — OSS returns an error.
callbackBodyType sets the Content-Type header in the callback request. Valid values:
| Value | Notes |
|---|---|
application/x-www-form-urlencoded | Default |
application/json | — |
Examples
The following shows a decoded callback parameter with an invalid callbackBodyType value.
Incorrect — callbackBodyType is a number, not a string:
{
"callbackUrl": "www.oss-callback.com/test.php",
"callbackBody": "{\"mimeType\":${mimeType},\"size\":${size}}",
"callbackBodyType": 123
}Correct — callbackBodyType is a string:
{
"callbackUrl": "www.oss-callback.com/test.php",
"callbackBody": "{\"mimeType\":${mimeType},\"size\":${size}}",
"callbackBodyType": "application/x-www-form-urlencoded"
}Solutions
Set callbackBodyType to "application/x-www-form-urlencoded" or "application/json". If you omit the field, OSS defaults to application/x-www-form-urlencoded.
References
Upload callbacks — how the upload callback feature works and how to configure it
Callbacks — API reference for the callback parameter
Upload callbacks — common errors — other errors you may encounter when configuring upload callbacks
Overview — how to obtain server-side signatures, configure upload callbacks, and upload directly to OSS using HTML forms
Set up upload callbacks for mobile apps — configuring upload callbacks in a mobile app direct-transfer setup