Skip to content

BatchApi::create returns Error model on HTTP 201 — missing case 201 in response switch #603

@jhellemeister-tb

Description

@jhellemeister-tb

Bug Report

Package: hubspot/api-client
Version: 14.0.5
File: codegen/Crm/Objects/Api/BatchApi.php

Description

The createWithHttpInfo method (and likely its async counterpart) only handles
HTTP 200 as a successful response in its status-code switch. However, the
HubSpot API returns 201 Created for batch-create operations.

Because 201 is not matched by case 200:, it falls through to default:,
which deserializes the response body as an Error model instead of
BatchResponseSimplePublicObject. This causes callers to receive an Error
object even when the request succeeded.

Affected code (line 448 ff.)

switch($statusCode) {
    case 200:
        return $this->handleResponseWithDataType(
            '\HubSpot\Client\Crm\Objects\Model\BatchResponseSimplePublicObject',
            $request,
            $response,
        );
    default:
        return $this->handleResponseWithDataType(
            '\HubSpot\Client\Crm\Objects\Model\Error',
            $request,
            $response,
        );
}

Expected behaviour

A 201 response should be treated as success and deserialized as
BatchResponseSimplePublicObject, the same way 200 currently is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions