Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.63k stars 2.84k forks source link

Incorrect example create_or_update body #32731

Open smokethis opened 1 year ago

smokethis commented 1 year ago

Have spent ages trying to troubleshoot this issue and found the root cause.

Problem

In the official documentation the example body for a filter.create_or_update request is:

   body = {
       "id": "str",  # Optional.
       "name": "str",  # Optional.
       "properties": {
           "excludeUriPrefixes": [
               "str"  # Optional.
           ],
           "includeUriPrefixes": [
               "str"  # Optional.
           ]
       }
   }

However, using this never works and Purview emits an HTTP 400 error with no further details.

Solution

Having traced the Purview Web UI behaviour when making the same change, I have found that the request body should actually contain the following:

   body = {
       "id": "str",  # Optional.
       "name": "str",  # Optional.
       "properties": {
           "excludeUriPrefixes": [
               "str"  # Optional.
           ],
           "includeUriPrefixes": [
               "str"  # Optional.
           ],
       "excludeRegexes": "str", # Mandatory.
       "includeRegexes": "str" # Mandatory.
       }
   }

When specifying the excludeRegexes and includeRegexes properties in the request through the SDK, specifying them as None, the request is successfully processed and the scan filter is updated.

Please check and update documentation and handle this error correctly to inform consumers of the incorrect request body content.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

xiangyan99 commented 1 year ago

Thanks for the feedback, we’ll investigate asap.