Search code examples
azurerestpostmanazure-rest-api

how to pass parameters in azure pipeline using rest api?


I'm using postman to make rest requests to the azure API to run a pipeline that is in synapse, in terms of permissions and the token I already get them and it works, the problem is that the pipeline receives 3 parameters but I don't know how to pass them, so I have this request, example:

https://hvdhgsad.dev.azuresynapse.net/pipelines/pipeName/createRun?api-version=2020-12-01

and the parameters I added them in the body:

{
    "parameters": {
        "p_dir": {
            "type": "string",
            "defaultValue": "val1"
        },
        "container": {
            "type": "string",
            "defaultValue": "val"
        },
        "p_folder": {
            "type": "string",
            "defaultValue": "val3"
        }
    }
}

but when I validate the run that was launched with the request I get this.

{
    "id": "xxxxxxxxxxxxxxx",
    "runId": "xxxxxxxxxxxxxxxxxxxxx",
    "debugRunId": null,
    "runGroupId": "xxxxxxxxxxxxxxxxxxxx",
    "pipelineName": "xxxxxxxxxxxxxxxxx",
    "parameters": {
        "p_dir": "",
        "p_folder": "",
        "container": ""
    },
    "invokedBy": {
        "id": "xxxxxxxxxxxxxxxxx",
        "name": "Manual",
        "invokedByType": "Manual"
    },
    "runStart": "2021-07-20T05:56:04.2468861Z",
    "runEnd": "2021-07-20T05:59:10.1734654Z",
    "durationInMs": 185926,
    "status": "Failed",
    "message": "Operation on target Data flow1 failed: {\"StatusCode\":\"DF-Executor-SourceInvalidPayload\",\"Message\":\"Job failed due to reason: Data preview, debug, and pipeline data flow execution failed because container does not exist\",\"Details\":\"\"}",
    "lastUpdated": "2021-07-20T05:59:10.1734654Z",
    "annotations": [],
    "runDimension": {},
    "isLatest": true
}

the params are empty, so I don't know what's wrong or missing. what is the correct way to pass them???

ref: https://learn.microsoft.com/en-us/rest/api/synapse/data-plane/pipeline/create-pipeline-run#examples


Solution

  • Just created an account to answer this as i've had the same issue.

    I resolved this by just having the name of the variable and its subsequent value in the body JSON.

    e.g.

    {"variable": "value", "variable": "value"} 
    

    Found this by following the documentation you had posted, under request body it passes the name of the variable and the value directly into the JSON body.

    {
      "OutputBlobNameList": [
        "exampleoutput.csv"
      ]
    }
    

    This particular example is a list/array so it confused me by adding the brackets [] if you are passing string parameters this is unneeded.