microsoft / vscode-powerquery-sdk

Power Query Connector Development SDK for VS Code
MIT License
71 stars 11 forks source link

WebAction.Request with WebMethod.Put failed with ActionNotAllowed #284

Closed brice-automatizit closed 9 months ago

brice-automatizit commented 1 year ago

Preflight Checklist

Power Query SDK

0.2.3

Regression From

No response

Platform

Windows

Architecture

x64

OS Version

Windows_NT x64 10.0.22621

VSCode version

1.80.2

PQSdkTool Path

No response

Bug Description

I need to update a secret after it usage. I was thinking about Azure Keyvault which use the PUT method on the secret endpoint.

shared TestConnector.Contents = () =>
    let
        token = GetTokenAzure("https://vault.azure.net"),
        header = [Headers=[#"Authorization"="Bearer "&token,#"content-type"="application/json",accept="application/json"]],
        postData = Json.FromValue(
            [
                value="testupdatefromvisual"
            ]
        ),
        options = [
            Headers = header,
            Content = postData
        ],
        Test = WebAction.Request(WebMethod.Put,"https://<my vaultname>.vault.azure.net/secrets/<secret-name>?api-version=7.4",options)
    in
        Test;

The following code gives me the following output

[2:39:24 PM]    [Info]  RunTestBattery result [
    {
        "ActivityId": "e2bce05c-97c4-4953-9de4-71863d22e9a6",
        "DataSourceAnalysis": [
            {
                "Kind": "DataSource",
                "FunctionName": "TestConnector.Contents",
                "DataSource": {
                    "Kind": "TestConnector",
                    "NormalizedPath": "TestConnector",
                    "Path": "TestConnector"
                }
            }
        ],
        "Details": "Nous n'avons pas l'autorisation d'effectuer des actions sur cette source TestConnector.",
        "EndTime": "2023-07-28T12:39:23.9455535+00:00",
        "Method": "PQTest.RunTest",
        "Name": "TestConnector.query.pq",
        "StartTime": "2023-07-28T12:39:22.5173152+00:00",
        "RowCount": 0,
        "Status": "Failed",
        "Type": "PQTest.Expression",
        "Error": {
            "Message": "Nous n'avons pas l'autorisation d'effectuer des actions sur cette source TestConnector.",
            "Details": {
                "Microsoft.Data.Mashup.CredentialError.Reason": "ActionNotAllowed",
                "Microsoft.Data.Mashup.CredentialError.DataSourceKind": "TestConnector",
                "Microsoft.Data.Mashup.CredentialError.DataSourcePath": "TestConnector",
                "Microsoft.Data.Mashup.MashupSecurityException.Reason": "ActionNotAllowed",
                "Microsoft.Data.Mashup.MashupSecurityException.DataSources": "[{\"kind\":\"TestConnector\",\"path\":\"TestConnector\"}]"
            }
        }
    }
]

Steps to Reproduce

Run a simple WebAction.Request() call even from custom connectors

Actual Experience

We should be able to use PUT, PATCH from refresh scenario.

Expected Experience

No response

Additional Context

No response

mattmasson commented 9 months ago

We currently do not have a roadmap for enabling WebAction.Request (and other functions that return M action values) through the PQ SDK.