Showing results for 
Search instead for 
Did you mean: 
Regular Visitor

Power Platform Build Tools: Connection reference


So we successfully implemented ALM with some Azure DevOps Pipelines and the official Power Platform Build Tools. But there's one problem:

When importing a solution which contains a Flow and its connection reference, it doesn't update itself correctly and just turns itself off.
It is as if I would import the solution with the old solution explorer UI. The new PowerApps solution UI asks when importing to update the connection references. But the old UI and the Power Platform Build Tools in Azure DevOps just disable the Flow.

So after having everything automated, we still have to go into the prod environment and update each connection reference and activate each Flow (even if it didn't change). I guess the process is worse now than without ALM.

Are there any workarounds or possibilities to use the "new UI" import API? Or am I missing something? How should this be handled with ALM?


Hi @ryanspain ,


I just don't see what could be wrong compared to the example you gave above.  One issue I thought about is perhaps because I'm trying to modify a Managed Solution. 



$tenantId = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
$appId = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
$appSecret = ""
$serviceUrl = ""

<# Get Access Token #>
$authContextUrl = "$tenantId"
$authContext = New-Object Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext($authContextUrl)
$credential = New-Object Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential($appId, $appSecret)
$authResult = $authContext.AcquireToken($serviceUrl, $credential)

<# Set Headers #>
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("CallerObjectId", "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx")
$headers.Add("Authorization", "Bearer " + $authResult.AccessToken )
$headers.Add("Content-Type", "application/json")

<# Set Body #>
$body = "{ 'statecode': 1, 'statuscode': 2 }"

<# Run Request #>
try {
	$response = Invoke-WebRequest -Uri '' -Method 'PATCH' -Headers $headers -Body $body
	exit 0
	"Status Code: $($_.Exception.Response.StatusCode.value__)"
	"Exception Message: $($_.Exception.Message)"
	exit 1


I've tried your code and it works for me @ScottCostello.


I even tried activating a cloud flow within a managed solution but that worked as expected too.


Could you try adding the below to your catch statement to try and extract the error message?

$result = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($result)
$reader.BaseStream.Position = 0
$responseBody = $reader.ReadToEnd()
"Response Body:  $($responseBody)"


The response should be something like the below:




This is the error message I get @ryanspain 


      "message":"An error occurred while validating input parameters: System.ArgumentException: Stream was not readable.\r\n   at System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen)\r\n   at System.IO.StreamReader..ctor(Stream stream, Encoding encoding)\r\n   at Microsoft.OData.JsonLight.ODataJsonLightInputContext.CreateTextReader(Stream messageStream, Encoding encoding)\r\n   at Microsoft.OData.JsonLight.ODataJsonLightInputContext..ctor(ODataMessageInfo messageInfo, ODataMessageReaderSettings messageReaderSettings)\r\n   at Microsoft.OData.Json.ODataJsonFormat.CreateInputContext(ODataMessageInfo messageInfo, ODataMessageReaderSettings messageReaderSettings)\r\n   at Microsoft.OData.ODataMessageReader.ReadFromInput[T](Func`2 readFunc, ODataPayloadKind[] payloadKinds)\r\n   at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)\r\n   at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)"

@ScottCostello, unfortunately that error message doesn't provide us with much other than there is a problem with the inputs.


Could you try changing the body statement in PowerShell to match the below? This is a long shot!



$body = "{
`n    `"statecode`": 1,
`n    `"statuscode`": 2



Also, what version of PowerShell is this executing on? i.e. run Get-Host | Select-Object Version.

New Member


how can I get the correct authority URL?


gives me the following error:

New-Object : Cannot find type [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext]: verify that the
assembly containing this type is loaded.


thanks for your help.


Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Users online (2,126)