web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Pages - General Discussions
Unanswered

Error with web api call

(0) ShareShare
ReportReport
Posted on by

Hey,

i have following problem.

I need to check if contact(accounts) exists.

 

async function signIn() {
    console.log('signIn function called');
    const email = document.getElementById('email').value;
    const password = document.getElementById('password').value;
   
    if (!email || !password) {
        alert('Please fill in both fields');
        return;
    }

    try {
        const response = await webapi.safeajax({
            type: 'GET',
            url: `/api/contacts?$filter=emailaddress1 eq '${email}' and adx_identity_passwordhash eq '${password}'`,
            contentType: 'application/json'
        });

        if (response.value && response.value.length > 0) {
            alert('Accountdaten richtig');
        } else {
            alert('Accountdaten falsch');
        }
    } catch (error) {
        console.error('Error:', error);
        alert('An error occurred during sign in');
    }
}
 
I get always the catch error, while in other sites on the website it works perfectly.
 
Anybody can help?
Categories:
I have the same question (0)
  • Inogic Profile Picture
    1,122 Super User 2025 Season 2 on at
    Re: Error with web api call

    Hi @Cris33 ,

    As per our understanding, you are facing the issue of validating if a contact exists or not, and you are encountering an issue with the web API.

     

    Here is the corrected signIn function:

    async function signIn() {

        console.log('signIn function called');

        const email = document.getElementById('email').value;

        const password = document.getElementById('password').value;

     

        if (!email || !password) {

            alert('Please fill in both fields');

            return;

        }

     

        try {

            const url = `/api/contacts?$filter=emailaddress1 eq ${encodeURIComponent("'" + email + "'")} and adx_identity_passwordhash eq ${encodeURIComponent("'" + password + "'")}`;

            const response = await webapi.safeajax({

                type: 'GET',

                url: url,

                contentType: 'application/json'

            });

     

            if (response.value && response.value.length > 0) {

                alert('Accountdaten richtig');

            } else {

                alert('Accountdaten falsch');

            }

        } catch (error) {

            console.error('Error:', error);

            alert('An error occurred during sign in');

        }

    }

     

    Refer to the following link for more information about using web API in PowerApps Portals: https://www.inogic.com/blog/2021/03/execute-different-web-api-operations-using-powerapps-portals-preview/

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 48

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 39 Super User 2025 Season 2

#3
Fubar Profile Picture

Fubar 35 Super User 2025 Season 2

Last 30 days Overall leaderboard