asRequestBody

Converts a ByteArray into a TracyHttpRequestBody based on the provided contentType. The given ByteArray is decoded according to the specified charset.

This method interprets the byte array input as either JSON or multipart form data, depending on the specified contentType. If the contentType is recognized as application/json, the method attempts to parse the byte array into a JSON object. For multipart/form-data, it parses the byte array into a form data structure.

Return

A TracyHttpRequestBody instance representing the parsed content, or null if the contentType is unsupported or parsing fails.

Parameters

contentType

The mime type of the data (e.g., application/json). Used to determine how to interpret the byte array.

charset

The character encoding used to decode the byte array.