loopback-sdk-builder
loopback-sdk-builder copied to clipboard
Custom remoteMethod with POST is generated as GET
What type of issue are you creating?
- [x] Bug
- [ ] Enhancement
- [ ] Question
What version of this module are you using?
- [ ] 2.0.10 (Stable)
- [x] 2.1.0-rc.n (2.1 Release Candidate n)
- [x] Other
Issue: Data which should be posted in body is appended to URL. I discovered this when server gave me 414 URI Too Long.
Details: The generated a custom function in service/custom/Mymodel.ts has correctly _method = POST, but data which should be in _postBody is in _urlParams.
yeah, I've seen that a lot recently as well. very confusing - and not nice on the eye for the generated url ;)
Hi guys thanks for reaching out..
Hey so, the sdk right now is not deciding the type of data based on your remote method HTTP method, but it addresses your arguments configurations.
In other words the SDK is only addressing the HTTP Mapping from arguments configurations
{ arg: 'data', type: 'object', http: { source: 'body' } }
Reference: https://loopback.io/doc/en/lb2/Remote-methods.html#http-mapping-of-input-arguments
If you don't map your arguments the SDK by default will send everything through query params which is default.
Once you correctly configure your arguments, your generated remote method will work as you expect.
Of course it can be improved and also address HTTP Methods to decide the type of the parameter in case the HTTP Mapping is not provided. PRs Are Welcome :)
Regards Jon
+1
I am using version number: 2.1.1 @jonathan-casarrubias having same exact issue on our side. I manually changed the code in the generated sdk on my end. to from _postbody instead of _urlParams.
Any updates on this issue?