- Issue created by @kopeboy
- Assigned to nikolas.costa
- Status changed to Needs review
about 1 year ago 12:08pm 16 January 2024 - 🇮🇹Italy nikolas.costa Rome
Hi @kopeboy,
it's likely that the error is in the definition of the service variables. Nevertheless, here is the link to the official documentation of the module:Additionally, within the module itself, you will find a sample module; you can refer to the following link:
- 🇮🇹Italy kopeboy Milan
If you open the attachment you can notice I've exactly followed the documentation and the example.
The api is very easy, could you check to confirm if this is a bug?
Thank you. - 🇮🇹Italy kopeboy Milan
I've identified a difference with I had changed while trying to make it work, which was in the my_module.http_services_api.yml > my service > api_path:
src.apy.nano.yml
and/src/api/resources/nano.yml
both strangely would lead to the same results (the http client would show in the admin pages and the "account_balance" POST req. will result in an empty response. - 🇮🇹Italy kopeboy Milan
I even tried moving the operations definition in the src/api/nano.yml, away from the src/api/resources/nano.yml (leaving only the models there) as I've seen in this video https://www.youtube.com/live/9a3Z63AJP4o?si=vMeKi9J5jnQEvpHG&t=9727
Nothing changed.
- 🇮🇹Italy kopeboy Milan
After further testing I can say that GET requests work while POST requests don't (even from other APIs, I'm always getting 400 Bad request), so I guess I need some more code in my custom module for those.. but it's not documented.
- 🇮🇹Italy kopeboy Milan
I probably found the error depends on my local DDEV container (see: https://github.com/ddev/ddev/issues/5704).
Still not sure because i'm not an expert.
I will update & close this issue when resolved, sorry for the noise (I hope it will help others). - Status changed to Needs work
about 1 year ago 5:01pm 17 January 2024 - 🇮🇹Italy kopeboy Milan
I found the error!
In the Guzzle service description (under
my_module/src/api/resources/
) > operations > your_operation > parameters: I was usinglocation: body
instead oflocation: json
!!In the documentation (see https://www.drupal.org/docs/contributed-modules/http-client-manager/guzz... → , under location) "body" is listed as a possible value so it may be useful to show an example on how to use it, or explicitly suggest to use "json" instead.
- Status changed to Closed: works as designed
about 1 year ago 9:17am 19 January 2024 - 🇮🇹Italy aronne
Hi @kopeboy
please consider that Guzzle documentation is out of the scope of this module and HTTP Client Manager is just a wrapper around Guzzle.Anyway I've updated the documentation hoping it's clear enough now and that it could help people in the future understanding which location parameter should be used.
Thank you again for your contribution,
aronne.