Thanks for posting this good question, Satyam.
While I’m checking on this, could you please share the following info.
As I understand you have not used any custom domain for Webapp and your using public IP to access the API. Kindly let me know if I have misunderstood/highlight more about your scenario.
Typically, the error message "Failed to load resource: net::ERR_CERT_INVALID" indicates that the SSL certificate used by your Application Gateway is not trusted by the client machine. This can happen if the SSL certificate is self-signed or if it is issued by a certificate authority (CA) that is not trusted by the client machine.
To connect to App Service, Application Gateway uses the default domain as provided by App Service (suffixed "azurewebsites.net") Or recommended approach via custom domain.
Have you tried the suggestions outlined in this doc? Configure App Service with Application Gateway