Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to send PATCH for custom objects #557

Open
emergingdzns opened this issue Mar 7, 2025 · 0 comments
Open

Unable to send PATCH for custom objects #557

emergingdzns opened this issue Mar 7, 2025 · 0 comments

Comments

@emergingdzns
Copy link

We are attempting to update custom objects following the documentation for updated by external id (https://developer.zendesk.com/api-reference/custom-data/custom-objects/custom_object_records/#set-custom-object-record-by-external-id-or-name)

However, the only way to send a PATCH method is to do something like this:

$client->post($url, $data, ['method' => 'PATCH']);

But when I try that, I'm getting this error:

An error occurred calling API. Error: Client error: `POST https://bubblebinzfranchisellc.zendesk.com/api/v2/custom_objects/service_request/records?external_id=20693` resulted in a `422 Unprocessable Entity` response:
{"error":"RecordInvalid","description":"Record validation errors","details":{"external_id":[{"description":"This externa (truncated...)
 [details] {"error":"RecordInvalid","description":"Record validation errors","details":{"external_id":[{"description":"This external ID is already in use."}]}}

So I looked into the HttpClient class and check the post method there. You have the array_merge backwards I think. The $options being sent in containing 'method' => 'PATCH' is getting overridden by the POST method in the second array.

        $extraOptions = array_merge($options, [
            'postFields' => $postData,
            'method' => 'POST'
        ]);

In my local system, I modified the class and reversed it as such:

        $extraOptions = array_merge([
            'postFields' => $postData,
            'method' => 'POST'
        ], $options);

And it works perfectly fine. But I don't have a way to do that on the server because this is controlled by composer.

Can you please make this adjustment ASAP?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant