Closed svendecabooter closed 5 years ago
Hi @svendecabooter, thanks for the detailed writeup. The idea behind the MultipleMethodsTrait
is to provide the ability to perform the request in multiple ways (since the Teamleader API supports this for some endpoints).
This is definitely a bug. A request extending the PostRequest
should default to POST
as method. @yoerioptr might be able to look into this. We could fix the bug, or maybe think of some alternative way to change the method of the request classes.
Hi @svendecabooter, Thanks for reporting the issue. It should be fixed by now.
Thanks for the quick followup @yoerioptr & @mark-gerarts !
I'm using the v2-refactor branch, to integrate Teamleader with a Drupal 8 site.
When adding a new draft invoice, I'm getting the following error:
When debugging, it seems the $method property of the \Nascom\TeamleaderApiClient\Request\Invoicing\Invoices\InvoicesDraftRequest class is set to NULL. It should use POST from its PostRequest class inheritance, but it seems the usage of MultipleMethodsTrait overrides this.
Since the method is NULL, it gets set to GET by default.
See the screenshot of my debugger, in \League\OAuth2\Client\Provider\AbstractProvider::createRequest():
Interestingly, when trying to add new contact, I also did debugging to see the difference. There the same problem occurs, and the method used is also GET.
But it seems in the latter case the Teamleader API does not reject the call, but in the former it does.
Do we need to call setMethod() explicitly in Request classes where a POST is desired? Or what would be the appropriate way to handle this?