OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Using REST API in Python to run Workflows in Azure Purview

  • Thread starter Thread starter Ric S
  • Start date Start date
R

Ric S

Guest
We are trying to use Purview REST APIs to make a user request that should be able to trigger a Purview workflow run. The workflow should trigger whenever the user is trying to update an asset, for example its description.

According to the REST API documentation, we are using the following code:

Code:
import requests

url = f"https://XXXXX.purview.azure.com/workflow/userrequests?api-version=2023-10-01-preview"

headers = {
    "Authorization": f"Bearer {token}",   # each time generated
    "Content-Type": "application/json"
}

body = {
    "operations": [
        {
            "type": "UpdateAsset",
            "payload": {
                "entities": {
                    "typeName": "azure_sql_table",
                    "attributes": {
                        "guid": "f00553c6-7a45-479f-b2fe-f9f6f6f60000",
                        "userDescription": "New description from ADB via workflow API",
                        "qualifiedName": "mssql://XXXXX.database.windows.net/XXXXX/dbo/YYYYY",
                        "name": "YYYYY",
                        "description": "Description field from ADB via workflow API"
                    }
                }
            }
        }
    ],
    "comment": "Thanks!"
}

response = requests.post(url, headers=headers, json=body)
response.json()

The response we are getting is:

Code:
{'error': {'requestId': '3ea14555-aa4c-48e7-b1b6-1d683f39515b',
  'code': 'Workflow.DataCatalogError.InvalidJsonRequestPayload',
  'message': "Invalid Json request payload: '.entities(missing)'"}}

We do not understand what is missing inside "entities". There is a similar issue here.
What are we doing wrong?
<p>We are trying to use Purview REST APIs to make a user request that should be able to trigger a Purview workflow run. The workflow should trigger whenever the user is trying to update an asset, for example its description.</p>
<p>According to the <a href="https://learn.microsoft.com/en-us/r...orkflowdataplane-2023-10-01-preview&tabs=HTTP" rel="nofollow noreferrer">REST API documentation</a>, we are using the following code:</p>
<pre><code>import requests

url = f"https://xxxxx.purview.azure.com/workflow/userrequests?api-version=2023-10-01-preview"

headers = {
"Authorization": f"Bearer {token}", # each time generated
"Content-Type": "application/json"
}

body = {
"operations": [
{
"type": "UpdateAsset",
"payload": {
"entities": {
"typeName": "azure_sql_table",
"attributes": {
"guid": "f00553c6-7a45-479f-b2fe-f9f6f6f60000",
"userDescription": "New description from ADB via workflow API",
"qualifiedName": "mssql://XXXXX.database.windows.net/XXXXX/dbo/YYYYY",
"name": "YYYYY",
"description": "Description field from ADB via workflow API"
}
}
}
}
],
"comment": "Thanks!"
}

response = requests.post(url, headers=headers, json=body)
response.json()
</code></pre>
<p>The response we are getting is:</p>
<pre><code>{'error': {'requestId': '3ea14555-aa4c-48e7-b1b6-1d683f39515b',
'code': 'Workflow.DataCatalogError.InvalidJsonRequestPayload',
'message': "Invalid Json request payload: '.entities(missing)'"}}
</code></pre>
<p>We do not understand what is missing inside "entities". There is a similar issue <a href="https://learn.microsoft.com/en-us/a...t-to-submit-a-a-user-request?comment=question" rel="nofollow noreferrer">here</a>.<br />
What are we doing wrong?</p>
 

Latest posts

Top