My WAF was creating the CORS policy issue. Disabled CORS on WAF server.
Thanks, fix wored.
I found the issue:
the solution is to move the if null statement before it converts to Int 64.