As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
I can't find an example of accessing a Custom Endpoint from within a Collection Hook. The HTML5 guides show that Endpoints are accessed via the Kinvey.execute method. In Business Logic there is no Kinvey object.
So, how can I access a custom endpoint from within a pre/post collection hook?
You would have to make a REST call to it - http://devcenter.kinvey.com/rest/guides/business-logic#invoking-endpoint
Be careful not to make a cycle, as your backend will be blacklisted (denied access to BL for 1hr).
J
Justin Noel
said
about 10 years ago
Looking at the docs for REST API, I see that I can post to the End Point. So, I played around in the API console and was able to successfully hit my endpoint.
However.... This is not really a good solution. the POST requires 2 critical things. The first is 'authorization'. The second is 'appKey'. In my collection hook, I could hardcode these values in. However, it will all fail when I push my code to production. Right now, I'm in the "development" environment. So, the 'authorization' and 'appKey' are for development. If I hardcode them into my collection hook, they will not work when I go to production.
Actually, they MIGHT work, but the PRODUCTION collection hook will be querying the DEVELOPMENT endpoint. This is a recipe for disaster.
So.. I hope Kinvey has a better solution.
J
Justin Noel
said
about 10 years ago
Ivan - You must have answered while I was typing my "answer". Please see my issues with using a REST call to it.
I
Ivan Stoyanov
said
about 10 years ago
The appKey you can dynamically get from http://devcenter.kinvey.com/rest/reference/business-logic/reference.html#backendcontext-module
For Authorization you have two options - just "forward" the incoming authorization header, in which case the endpoint will be called with the same credentials as the hook, or just do basic auth with the appKey:masterSecret. (BasicAuth doc - http://devcenter.kinvey.com/rest/guides/security#basicauthentication)
I guess we could provide wrappers to make this dead simple, but it doesn't feel too difficult?
J
Justin Noel
said
about 10 years ago
Ivan,
I've struggled with this for 2 days. I can't come up with a onPreSave collection hook that calls my custom End point. See here. http://support.kinvey.com/hc/communities/public/questions/200359896-Working-Example-of-The-Request-Module-Using-POST-
If you've got a sample, of something that works, that would be amazingly useful.
Thanks,
Justin
J
Justin Noel
said
about 10 years ago
Consider this closed. See http://support.kinvey.com/hc/communities/public/questions/200359896-Working-Example-of-The-Request-Module-Using-POST-
Justin Noel
So, how can I access a custom endpoint from within a pre/post collection hook?