Calling a Function from Custom code

It is for certain authentication methods. However if the others work then its fine. Get it working in swagger / postman first.

If you are getting 500 error (what is the message)
What does your function look like (what is it doing)
Go to the Server and look at the Event Viewer on that 500 error it should give you more details.