Start a new topic

Can not use hooks on user collection

I just want to use collection hook on user collection. But event with the simplest code:

function onPreFetch(request, response, modules) { 
  response.continue();
}

I receive (during a test) following:

{"error":"IndirectCollectionAccessDisallowed","description":"Please use the appropriate API to access this collection for this app backend","debug":"You cannot access the user collection through the appdata API"}

Is this mean that I cannot use hooks at all for user collection?

Andrzej,


As we know that there is an issue with 'Testing' button in the hook editor for Users collection and you can not use it for testing.


But you can use Kinvey API console for testing on Users collection. Once you login into the console and select your app, you can click on "API Console".


image



You can call different functions on Users collection and the Users collection hooks will get executed. You can confirm it in hook editor logs.


Please take a look at Basic User Operations.



Thanks,

Pranav

Andrzej,

I have checked this and able to see the issue. I am escalating this issue to engineering and get back to you once I hear back form them.

Thanks,
Pranav
BACK-3079

 

Thanks for this explanation. But how to make "Testing" environment in hook editor to make call to /user and not to /appdata ? I do not see any possibility in the editor interface to change it. It shouldn't be like that editor will choose appropriate end point while testing? 


It was not my fault to select wrong path, but Testing environment in hook editor. How to change this? It makes Testing useless for user collection...

Andrzej,


You can use hooks for user collection. You are getting "IndirectCollectionAccessDisallowed" because the URL for calling user collection was wrong.


You used (Wrong): /appdata/<<your kid>>/user

You should use (Correct): /user/<<your kid>>/userid  (Please check https://devcenter.kinvey.com/rest/guides/users#retrieve)

Also, please go through the following link for better understanding of collection hooks, custom endpoints etc.
https://devcenter.kinvey.com/rest/guides/business-logic#types


Let me know if above suggestion helps you.

Thanks,
Pranav
Kinvey


Login or Signup to post a comment