IOTA - SDK and Empty Body Errors
You may encounter the following error log when attempting to submit a request to IOTA via Tatum using the IOTA SDK.
IOTA SDK Error
{
"id": "###",
"method": "POST",
"url": "/v3/blockchain/node/iota-testnet/api/core/v2/blocks",
"agent": "iota-sdk/1.1.4",
"ip": "###",
"timestamp": ###,
"request": {
"body": {}
},
"response": {
"error": {
"code": "400",
"message": "invalid parameter, error: failed to attach block: protocolVersion invalid: 0: invalid block: code=400, message=invalid parameter"
}
},
"code": 400,
"apiKey": "###",
"requestRayId": "###",
"userId": "###"
}
Key Error Messages:
- "message": "invalid parameter, error: failed to attach block: protocolVersion invalid"
- "code": 400, message=invalid parameter"
Cause
The primary issue here is with the Content-Type header set by the IOTA SDK, which is using application/vnd.iota.serializer-v1
instead of the standard application/json
.
This non-standard Content-Type prevents the Tatum API from parsing the request body properly, resulting in a 400 Bad Request error, as the request body appears empty in Tatumβs logs.
Troubleshooting Steps
- Verify the SDK Request Format:
Check that the IOTA SDK is indeed sending the request body in the expected format by examining the raw request data. You can use a network inspector tool or log the request details from your SDK to confirm the format. - Override the Content-Type Header:
If possible, configure the IOTA SDK to use application/json as the Content-Type. This adjustment may resolve the issue if the SDK allows header customization. - Convert Request to JSON Format:
If overriding the header isnβt an option, consider constructing the request manually in a way that adheres to Tatumβs requirements. Using a standard HTTP client (like Axios or Fetch in JavaScript, or Requests in Python) might allow for greater control over the request structure, including setting Content-Type to application/json.
Updated 1 day ago