Getting error when trying to use selective deploy pipelines - Power BI REST APIs

Satriadi, Bagus 0 Reputation points
2023-11-07T07:13:47.44+00:00

I have defined a function in python to call Power BI REST API - selective deploy pipelines.

def selective_deployment_pipeline(access_token: str, pipeline_id: str, source_stage_order: int, datasets_sid: str,  report_sid: str): # require scope: Pipeline.Deploy
    url = f"https://api.powerbi.com/v1.0/myorg/pipelines/{pipeline_id}/deploy"
    print(url)
    body={
        "sourceStageOrder": source_stage_order,
        "datasets": [
          {
            "sourceId": datasets_sid
          }
        ],
        "reports": [
          {
            "sourceId": report_sid
          }
        ],
        "options": {
            "allowOverwriteArtifact": "true",
            "allowCreateArtifact": "true"
        },
        "note": "Deploying business ready items"
    }
    #print(body)
    headers = {'Authorization': f'Bearer {access_token}', "Accept": None}
    response = requests.request("POST", url, headers=headers, data=body)
    json_response = json.loads(response.text)
    print("response:", json_response)

When i'm calling the script, although i've provided the datasets_id and reports_id altogether with rest of the required params, i got below error message:

response: {'error': {'code': 'BadRequest', 'message': 'Bad Request', 'details': [{'message': 'The SourceId property is required.', 'target': 'request.Datasets.SourceId'}, {'message': 'The SourceId property is required.', 'target': 'request.Reports.SourceId'}]}}

Please help. Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
9,137 questions
0 comments No comments
{count} votes