
Hey,
i have following problem.
I need to check if contact(accounts) exists.
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/