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 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:
I have the same question (0)
  • Inogic Profile Picture
    1,135 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 66

#2
Fubar Profile Picture

Fubar 45 Super User 2025 Season 2

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 31 Super User 2025 Season 2

Last 30 days Overall leaderboard