Power Automate: Get Page Author Details
Introduction
In Power Automate, retrieving details about the author of a SharePoint page can be essential for various workflows. This blog post will guide you through the steps to get the page author details using Power Automate.
- Add
Send an Http request to SharePoint
action and rename it toGet Page Author Details
.Configure the action with the following settings:
- Site Address: triggerOutputs()?[‘body/SiteUrl’]
- Method: Get
- Uri : /_api/web/_api/Web/GetUserById(body(‘Parse_Page_Details_JSON’)?[’d’]?[‘AuthorId’])
Output of the API
{
"d": {
"__metadata": {
"id": "https://contoso.sharepoint.com/sites/d-intranet-hub/_api/Web/GetUserById(14)",
"uri": "https://contoso.sharepoint.com/sites/d-intranet-hub/_api/Web/GetUserById(14)",
"type": "SP.User"
},
"Alerts": {
"__deferred": {
"uri": "https://contoso.sharepoint.com/sites/d-intranet-hub/_api/Web/GetUserById(14)/Alerts"
}
},
"Groups": {
"__deferred": {
"uri": "https://contoso.sharepoint.com/sites/d-intranet-hub/_api/Web/GetUserById(14)/Groups"
}
},
"Id": 14,
"IsHiddenInUI": false,
"LoginName": "i:0#.f|membership|srv_test@ppf.co.uk",
"Title": "SRV_test",
"PrincipalType": 1,
"Email": "SRV_test@ppf.co.uk",
"Expiration": "",
"IsEmailAuthenticationGuestUser": false,
"IsShareByEmailGuestUser": false,
"IsSiteAdmin": true,
"UserId": {
"__metadata": {
"type": "SP.UserIdInfo"
},
"NameId": "100320022e6dd3f5",
"NameIdIssuer": "urn:federation:microsoftonline"
},
"UserPrincipalName": "srv_test@ppf.co.uk"
}
}
- Add the
Parse JSON
action and rename it toParse JSON Author Details
. Configure the action with the following settings:
- Content: body(‘Get_Page_Author_details’)
- Schema:
{
"type": "object",
"properties": {
"d": {
"type": "object",
"properties": {
"__metadata": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"uri": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"Alerts": {
"type": "object",
"properties": {
"__deferred": {
"type": "object",
"properties": {
"uri": {
"type": "string"
}
}
}
}
},
"Groups": {
"type": "object",
"properties": {
"__deferred": {
"type": "object",
"properties": {
"uri": {
"type": "string"
}
}
}
}
},
"Id": {
"type": "integer"
},
"IsHiddenInUI": {
"type": "boolean"
},
"LoginName": {
"type": "string"
},
"Title": {
"type": "string"
},
"PrincipalType": {
"type": "integer"
},
"Email": {
"type": "string"
},
"Expiration": {
"type": "string"
},
"IsEmailAuthenticationGuestUser": {
"type": "boolean"
},
"IsShareByEmailGuestUser": {
"type": "boolean"
},
"IsSiteAdmin": {
"type": "boolean"
},
"UserId": {
"type": "object",
"properties": {
"__metadata": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"NameId": {
"type": "string"
},
"NameIdIssuer": {
"type": "string"
}
}
},
"UserPrincipalName": {
"type": "string"
}
}
}
}
}
- Use User Details in any subsequent actions
The parsed user details can be used in any subsequent actions, e.g. update author details of a news link to be the author of the original news.
For example, to get the login name of the author, use:
body('Parse_JSON_Author_Details')?['d']?['LoginName']
Conclusion
By following these steps, you can easily retrieve and use the page author details in your Power Automate workflows. This can be particularly useful for automating tasks that require author information.