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

POST method in requests seems unused? #12

Closed
svendecabooter opened this issue Apr 19, 2019 · 3 comments
Closed

POST method in requests seems unused? #12

svendecabooter opened this issue Apr 19, 2019 · 3 comments
Labels

Comments

@svendecabooter
Copy link

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():
Selection_007

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?

@mark-gerarts
Copy link
Collaborator

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.

@yoerioptr
Copy link

Hi @svendecabooter,
Thanks for reporting the issue. It should be fixed by now.

@svendecabooter
Copy link
Author

Thanks for the quick followup @yoerioptr & @mark-gerarts !

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

No branches or pull requests

3 participants