Get Content Type by Name
How to get a Content Type by filtering on the name in a SharePoint Online Content Type Gallery using the Graph API in a Power Automate flow.
URI
_api/v2.0/sites/@{variables('SiteId')}/contentTypes/getCompatibleHubContentTypes?$filter=name eq '@{variables('ContentTypeName')}' |
Headers
{ | |
"Accept": "application/json;odata=verbose", | |
"Content-Type": "application/json;odata=verbose" | |
} |
Body
Not applicable
Screenshot with example
Sample data
SiteId – contoso.sharepoint.com,9b5b287b-b65d-4a49-b663-672a6643104e,31290b46-1ffd-4fee-b16b-db271d10e184 (Content Type Hub site)
ContentTypeName – IT FAQ
Expected response
An array in the value property will be returned with properties like id, group, etc.
{ | |
"@odata.context": "https://contoso.sharepoint.com/sites/contentTypeHub/_api/v2.0/$metadata#sites('contoso.sharepoint.com%2C9b5b287b-b65d-4a49-b663-672a6643104e%2C31290b46-1ffd-4fee-b16b-db271d10e184')/contentTypes(base(base()))", | |
"value": [ | |
{ | |
"id": "0x0100C3EB6546C4FF294797E0A7719864F9E3", | |
"isBuiltIn": false, | |
"description": "Documentation owned and published by IT Services.", | |
"group": "Contoso Content Types", | |
"hidden": false, | |
"name": "IT FAQ", | |
"readOnly": true, | |
"sealed": false, | |
"base": { | |
"hidden": false, | |
"name": "Item", | |
"readOnly": false, | |
"sealed": false | |
} | |
} | |
] | |
} |
Copy/paste example
Copy and paste the below code via the My Clipboard option in Power Automate.
{"id":"52f45989-3415-401c-93db-a131f45db72f","brandColor":"#036C70","connectionReferences":{"shared_sharepointonline":{"connection":{"id":"/exp_sharedsharepointonline_e5efa"}}},"connectorDisplayName":"SharePoint","icon":"https://connectoricons-prod.azureedge.net/releases/v1.0.1682/1.0.1682.3677/sharepointonline/icon.png","isTrigger":false,"operationName":"Send_an_HTTP_request_to_SharePoint","operationDefinition":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_sharepointonline","operationId":"HttpRequest","apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"parameters":{"dataset":"@parameters('SPO_SiteCollection_ContentTypeHub (exp_SPO_SiteCollection_ContentTypeHub)')","parameters/method":"GET","parameters/uri":"_api/v2.0/sites/@{variables('SiteId')}/contentTypes/getCompatibleHubContentTypes?$filter=name eq '@{variables('ContentTypeName')}'","parameters/headers":{"Accept":"application/json;odata=verbose","Content-Type":"application/json;odata=verbose"}},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{"Initialize_variable_-_ContentTypeName":["Succeeded"]},"metadata":{"operationMetadataId":"4250f97b-cb30-4804-a4ea-9194333610e9"}}} |
Resources
contentType: getCompatibleHubContentTypes
That’s it, Happy testing!