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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Error with web api call
Power Pages
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:
  • Inogic Profile Picture
    1,297 Moderator on at

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 18

#2
11manish Profile Picture

11manish 16 Super User 2026 Season 2

#3
Harshit Chaubisa Profile Picture

Harshit Chaubisa 4

Last 30 days Overall leaderboard