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

Company/Product update via REST endpoint #281

Open
LazyAfternoons opened this issue May 5, 2021 · 0 comments
Open

Company/Product update via REST endpoint #281

LazyAfternoons opened this issue May 5, 2021 · 0 comments

Comments

@LazyAfternoons
Copy link

LazyAfternoons commented May 5, 2021

Hello, I'm trying to update a company/product via REST endpoint and I have the following code:

$data = ["id" => 123, "company_name" => "test"];
$infusionsoft->companies()->mock($data)->save();

This results in an error:

{"message":"Client error: PUT https://api.infusionsoft.com/crm/rest/v1/companies/123?access_token=xxx resulted in a 405 Method Not Allowed` response:\n (truncated...)\n"}

As far as I can see, the request for updating a company is actually a PATCH so that does make sense.
I then tried to add the following attribute into CompanyService.php:

protected $updateVerb = 'patch';

I now have the following error:

{"message":"Client error: PATCH https://api.infusionsoft.com/crm/rest/v1/companies/123?access_token=xxx resulted in a 400 Bad Request response:\n\n"}

With the following request:

{"id":123,"company_name":"test"}

Which again, makes sense, PATCH shouldn't have the 'id' parameter directly into the request but only in the URL.
The only workaround I found is to unset the ID before making a request if the $updateVerb equals to 'patch'.
I made the following change to the restfulRequest() in Infusionsoft.php:

if(strtolower($method) === 'patch'){
	unset($params['id']);
}

Am I doing something wrong? Is there another way to update companies or products via REST endopoints?
Thanks.

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