Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
821 views
in Technique[技术] by (71.8m points)

azure - Getting error DirectApiRequestHasMoreThanOneAuthorization when calling logic app using HTTP trigger

I have created a simple Logic app with HHT trigger response to take a test in JSON object and then pass it in teams channel. I have tested it successfully in Postman where I set Authorization type as "No Auth". When I am trying to call the same using powershell I am getting error
{"error":{"code":"DirectApiRequestHasMoreThanOneAuthorization","message":"The request has both SAS authentication scheme and 'None' authorization scheme. Only one scheme should be used."}} Below is the PowerShell code I am using . Please suggest what should I change in it.

$body ="{
      `"testName`": `"NewTest`"
      }"| ConvertTo-Json
$body  = $body | ConvertFrom-Json
$supportAreaUri = 'https://<URL>'
$supportAreaUri = [uri]::EscapeUriString($supportAreaUri)  
$Header = @{Authorization="None"}

Invoke-RestMethod -Method Post -Uri $supportAreaUri  -ContentType application/json -Body $body -Headers $Header

Here is the screenshot of logic app enter image description here

question from:https://stackoverflow.com/questions/65600530/getting-error-directapirequesthasmorethanoneauthorization-when-calling-logic-app

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When you created the logic app with "When a HTTP request is received" trigger, it will generate a url for request like https://prod-04.eastasia.logic.azure.com:443/workflows/830xxxxxxxxa5ebb/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=l5xxxxxxxxxxzMRM. The url is protected with SAS token, the SAS token follows the base url in querystring. When you request in postman, it will fill the querystring in "Params" like below screenshot: enter image description here

But when you request the url in powershell, you specify the header with Authorization="None", the request method will assume that you don't use any authentication and it is conflict with SAS token. So it shows the error message The request has both SAS authentication scheme and 'None' authorization scheme which you provided.

To solve this problem, you just need to request the url without -Header.

Invoke-RestMethod -Method Post -Uri $supportAreaUri  -ContentType application/json -Body $body

By the way: When you request the url without -Header, it may show this error message You do not have permissions to perform action 'run' on scope '/triggers/manual/paths/'. It was caused by the line $supportAreaUri = [uri]::EscapeUriString($supportAreaUri) . Actually, you do not need to do escapeUriString, so just remove this line and request again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...