Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Invoke-PnPSPRestMethod throws Exception in Azure Runbook #3451

Closed
2 of 6 tasks
EA12 opened this issue Sep 28, 2023 · 2 comments
Closed
2 of 6 tasks

[BUG] Invoke-PnPSPRestMethod throws Exception in Azure Runbook #3451

EA12 opened this issue Sep 28, 2023 · 2 comments
Labels
azure-automation Includes Azure Functions or Azure Runbooks bug Something isn't working

Comments

@EA12
Copy link

EA12 commented Sep 28, 2023

Reporting an Issue

AudienceUriValidationFailedException from Invoke-PnPSPRestMethod when using this cmdlet in an Azure Runbook

Expected behavior

The REST-Method should succeed

Actual behavior

Getting error:
{"error_description":"Exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' was thrown."}

image

Steps to reproduce behavior

Automation-Account has System-Identity
Related App-Registration has Sites.FullControl.All and User.ReadWrite.All for Graph and SharePoint

image

App-reg has a valid certificate and a valid Secret.
I have added App-Only (ACS) for this App-Reg at the admin site: https://mytenant-admin.sharepoint.com

Connecting:
$cnn = Connect-PnPOnline -Url $adminUrl -ClientId $clientId -ClientSecret $clientSecret -ReturnConnection

The API to use (to assign a UPS-Property)
$url = "https://mytenant.sharepoint.com/_api/SP.UserProfiles.PeopleManager/SetSingleValueProfileProperty"

Calling Invoke-PnPSPRestMethod throws the error:
$response = Invoke-PnPSPRestMethod -Url $url -Connection $cnn -Method 'POST' -ContentType 'application/json;odata=nometadata' -Content $Body

I couldn't find a code file here on github for Invoke-PnPSPRestMethod, just a documentation and an incomplete test.

What is the version of the Cmdlet module you are running?

My script is running in an azure runbook with PowerShell-runtime 5.1 and PnP.PowerShell 1.9.59

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Azure Runbook
@EA12 EA12 added the bug Something isn't working label Sep 28, 2023
@veronicageek veronicageek added the azure-automation Includes Azure Functions or Azure Runbooks label Sep 29, 2023
@gautamdsheth
Copy link
Collaborator

@EA12 - have you tried using Set-PnPUserProfileProperty cmdlet , should work the same way ? Looks like an issue with the API itself , so not sure if we can do anything here.

Maybe using this workaround #277 (comment) can help ?

@gautamdsheth
Copy link
Collaborator

Closing this due to lack of response.
Just FYI, ACS has been deprecated as of 27th Nov 2023, so we won't be fixing this specific issue

https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/retirement-announcement-for-azure-acs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-automation Includes Azure Functions or Azure Runbooks bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants