The SDKs now support passing complex objects, including non-scalar types and collections, as HTTP header parameters in the request.
Benefits
This update brings
- Enhanced Flexibility: Seamlessly send structured data in headers.
- Improved API Compatibility: Supports APIs that require complex header values.
- Simplified Implementation: Eliminates the need for manual serialization.
How It Works
The following code samples demonstrate how to pass complex objects as header parameters in different SDKs.
- Python
- Ruby
- PHP
- Java
- C#
- TypeScript
- Go
client = SdkClient(environment=Environment.PRODUCTION)
api_controller = client.api_controller
vehicle = Vehicle(
make='Toyota',
model='Camry',
year=2022,
engine=Engine(
horsepower=300,
fuel_type=FuelTypeEnum.PETROL
)
)
result = api_controller.send_vehicle_information_in_header(vehicle)
client = SdkClient.new(environment: Environment::PRODUCTION)
api_controller = client.api_controller
vehicle = Vehicle.new(
'Toyota',
'Camry',
2022,
Engine.new(
300,
FuelTypeEnum::PETROL
)
)
result = api_controller.send_vehicle_information_in_header(vehicle)
$client = new SdkClient(Environment::PRODUCTION);
$apiController = $client->getApiController();
$vehicle = new Vehicle([
'make' => 'Toyota',
'model' => 'Camry',
'year' => 2022,
'engine' => new Engine([
'horsepower' => 300,
'fuel_type' => FuelTypeEnum::PETROL
])
]);
$result = $apiController->sendVehicleInformationInHeader($vehicle);
SdkClient client = new SdkClient.Builder()
.environment(Environment.PRODUCTION)
.build();
ApiController apiController = client.getApiController();
Vehicle vehicle = new Vehicle.Builder(
"Toyota",
"Camry",
2022,
new Engine.Builder(
300,
FuelTypeEnum.PETROL
)
.build()
)
.build();
Result result = apiController.sendVehicleInformationInHeader(vehicle);
SdkClient client = new SdkClient.Builder()
.Environment(Environment.Production)
.Build();
APIController apiController = client.APIController;
var vehicle = new Vehicle
{
Make = "Toyota",
Model = "Camry",
Year = 2022,
Engine = new Engine
{
Horsepower = 300,
FuelType = FuelTypeEnum.Petrol,
},
};
var result = apiController.SendVehicleInformationInHeader(vehicle);
const client = new SdkClient({
timeout: 0,
});
const apiController = new ApiController(client);
const vehicle: Vehicle = {
make: 'Toyota',
model: 'Camry',
year: 2022,
engine: {
horsepower: 300,
fuelType: FuelTypeEnum.Petrol,
},
};
const { result, ...httpResponse } = await apiController.submitVehicleInformation(vehicle);
client := sdk.SdkClient(EnvironmentProduction)
apiController := client.ApiController()
ctx := context.Background()
vehicle := models.Vehicle{
Make: "Toyota",
Model: "Camry",
Year: 2022,
Engine: models.Engine{
Horsepower: 300,
FuelType: models.FuelTypeEnum_PETROL,
},
}
result, err := apiController.SendVehicleInformationInHeader(ctx, vehicle)