Skip to main content

How to create hook that blocking API Calls

Comments

5 comments

  • cPRex Jurassic Moderator
    Hey there! I'm not sure I completely understand what you are trying to do. Can you provide a different example or more details?
    0
  • andrzej.ol
    Hi, On every call Account::Create I want to check if my package is correct I want to do that in the hook, before create (pre). So I want to stop this call and return own result instead of standard api response. Shortly, I want to avoid account creating with that hook, Is that possible? if($package == 'wrong'){ // return message or result that would block api call return [0, 'Cannot create account, package is wrong'>; }
    0
  • cPRex Jurassic Moderator
    Thanks for the additional details. If you search this page for the word "block" you'll see details about the "blocking" variable, which I don't see present in your examples:
    0
  • andrzej.ol
    Hi, Thanks! It helped, but I spent more than 4 hours to check what is wrong with my code. In your documentation there is info that is should be [CODE=php]die("BAILOUT: $message");
    But it has to be [CODE=php]die("BAILOUT $message");
    0
  • cPRex Jurassic Moderator
    I'm so sorry there was a typo in the guide! I've submitted a case to our team to get that code example updated so that will be adjusted soon.
    0

Please sign in to leave a comment.