You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Client error: `GET https://api.teamleader.eu/invoices.draft` resulted in a `405 Method Not Allowed` response: @"errors":[{"code":405000,"title":"Method GET not allowed. Allowed method(s): POST","status":405]}
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?
The text was updated successfully, but these errors were encountered:
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.
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?
The text was updated successfully, but these errors were encountered: