Skip to main content

Notifications

Power Pages - General Discussions
Suggested answer

Use webapi to get all contacts who have "Administrators" role

(0) ShareShare
ReportReport
Posted on by 18
Hello everyone,
 
is it possible to use portals webapi to get all contacts who have "Administrators" role from contact table and how to do it?

Thanks in advance
Categories:
  • Suggested answer
    CU31070723-0 Profile Picture
    CU31070723-0 18 on at
    Use webapi to get all contacts who have "Administrators" role
    Hi SaiRT14,
     
     thanks a lot for your instructions! It didn't work for me (maybe because I'm using enhanced data model?) but using your instructions, I tried something else and came to a solution using this url:
     
    https://yourportalurl/_api/contacts?$select=fullname&$expand=powerpagecomponent_mspp_webrole_contact($filter=name eq 'Administrators')
     
    I had to set a table permission and Webapi site settings for "Site Component" table too.
  • Suggested answer
    SaiRT14 Profile Picture
    SaiRT14 1,666 on at
    Use webapi to get all contacts who have "Administrators" role
     
    Yes, it is possible to use the Portals Web API to retrieve all contacts who have the "Administrators" role.
     
    In Dataverse, the relationship between contacts and web roles is represented by a many-to-many relationship using an intermediate table: contactroles_association.
     
    The base URL for the Portals Web API: - https://yourportalurl/_api/contacts
     
    Use $filter and $expand to get contacts with the "Administrators" role: - GET https://yourportalurl/_api/contacts?$expand=contactroles_association($filter=webroleid eq 'WebRoleIDForAdministrators')
     
    Go to Portals Management App. Navigate to Web Roles and locate the "Administrators" role. Copy the GUID of the "Administrators" role (e.g., b1234567-89ab-cdef-0123-456789abcdef).
     
     
    If the GUID for the "Administrators" role is b1234567-89ab-cdef-0123-456789abcdef, the API call - GET https://yourportalurl/_api/contacts?$expand=contactroles_association($filter=webroleid eq 'b1234567-89ab-cdef-0123-456789abcdef')
     
     
    Check whether Web API enabled or not
    Navigate to Power Platform Admin Center > Portals > Settings. Enable Portals Web API.
     
    Set appropriate permissions for the Contact table: Navigate to Portals Management App > Entity Permissions. Create or update permissions for the Contact table to allow Read access for the required web roles.
     
    now test API with postman - hope this helps.

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

End of Year Newsletter…

End of Year Community Newsletter…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #11 New Opportunities…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,504

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,367

Leaderboard

Featured topics