PATCH method of the Sources API failing

I am having trouble updating a source attribute using the PATCH request type in the Sources API Python library. My script:

import sys
from sailpoint.v2025.api.sources_api import SourcesApi
from sailpoint.v2025.api_client import ApiClient
from sailpoint.v2025.models.json_patch_operation import JsonPatchOperation
from sailpoint.v2025.models.source import Source
from sailpoint.configuration import Configuration
configuration = Configuration()

source = sys.argv[1]
op = '''{"op":"replace", "path":"/connectorAttributes/deltaAggregationEnabled", "value":"false"}'''
operation = JsonPatchOperation.from_json(op)

with ApiClient(configuration) as api_client:
    try:
        results = SourcesApi(api_client).update_source(id=source, json_patch_operation=operation)
        print(results.model_dump_json(by_alias=True, indent=4))

    except Exception as e:
        print("Exception when calling SourcesApi->update_source: %s\n" % e)

The output when running this is as follows:

Exception when calling SourcesApi->update_source: 3 validation errors for SourcesApi.update_source
json_patch_operation.0
  Input should be a valid dictionary or instance of JsonPatchOperation [type=model_type, input_value=('op', 'replace'), input_type=tuple]
    For further information visit https://errors.pydantic.dev/2.11/v/model_type
json_patch_operation.1
  Input should be a valid dictionary or instance of JsonPatchOperation [type=model_type, input_value=('path', '/connectorAttri...eltaAggregationEnabled'), input_type=tuple]
    For further information visit https://errors.pydantic.dev/2.11/v/model_type
json_patch_operation.2
  Input should be a valid dictionary or instance of JsonPatchOperation [type=model_type, input_value=('value', UpdateMultiHost...int', 'object', 'str'})), input_type=tuple]
    For further information visit https://errors.pydantic.dev/2.11/v/model_type

Also, if the JsonPatchOperation is created in the way suggested on the API docs:

op = '''[{op=replace, path=/connectorAttributes/deltaAggregationEnabled, value=false}]'''
operation = JsonPatchOperation.from_json(op)

There is a different error, that I think makes more sense, but still doesn’t function properly. The docs may need an update since the string fed to from_json() isn’t valid JSON.

Exception when calling SourcesApi->update_source: Expecting property name enclosed in double quotes: line 1 column 3 (char 2)

Any suggestions to fix this?

Your second attempt is almost correct (i.e. using [ and ])…what’s missing there is that the “op” needs to be quoted (and everything else too, “replace”…etc)

First question i have is does this work with Postman? That validates the payload works there.

Second, if there is an issue with the Python API, that is something that the @developer_advocates would want to take back to their team to look at, as I believe they maintain that code. I do see that your second method is exactly how the example in the example code is. (Found here: Sources | SailPoint Developer Community) So based on that and @David_Norris (Terry You)'s suggestion, you may be correct that the documentation needs to be updated as well.

For this reason, I prefer using the PowerShell SDK instead.

e.g.

See if you have something like this on the Python side.

Update: Maybe code yours like this instead of a line of op = quoting hell

Hey @matt-wilks!

Can you try adding square brackets around the operation you pass in on this line?

results = SourcesApi(api_client).update_source(id=source, json_patch_operation=[operation])

You fully updated script would be:

import sys
from sailpoint.v2025.api.sources_api import SourcesApi
from sailpoint.v2025.api_client import ApiClient
from sailpoint.v2025.models.json_patch_operation import JsonPatchOperation
from sailpoint.v2025.models.source import Source
from sailpoint.configuration import Configuration
configuration = Configuration()

source = sys.argv[1]
op = '''{"op":"replace", "path":"/connectorAttributes/deltaAggregationEnabled", "value":"false"}'''
operation = JsonPatchOperation.from_json(op)

with ApiClient(configuration) as api_client:
    try:
        results = SourcesApi(api_client).update_source(id=source, json_patch_operation=[operation])
        print(results.model_dump_json(by_alias=True, indent=4))

    except Exception as e:
        print("Exception when calling SourcesApi->update_source: %s\n" % e)

@tyler_mairose Thanks! That seems to have worked. I think the API sample should be updated to reflect that: update-source | SailPoint Developer Community

Still not quite right for me since the value of deltaAggregationEnabled gets set to a literal string “false” instead of a boolean value, but I can work on that.

Thanks again!

In case it helps someone else, loading the JsonPatchOperation from a dictionary instead of a JSON string makes it possible to set Boolean values:

import sys
import pprint
from sailpoint.v2025.api.sources_api import SourcesApi
from sailpoint.v2025.api_client import ApiClient
from sailpoint.v2025.models.json_patch_operation import JsonPatchOperation
from sailpoint.v2025.models.source import Source
from sailpoint.configuration import Configuration
from sailpoint.v2025.models.update_multi_host_sources_request_inner_value import UpdateMultiHostSourcesRequestInnerValue
configuration = Configuration()

source = sys.argv[1]

op = {
    'op': 'replace',
    'path': '/connectorAttributes/deltaAggregationEnabled',
    'value': True
}
operation = JsonPatchOperation.from_dict(op)


with ApiClient(configuration) as api_client:
    try:
        # Update source (partial)
        results = SourcesApi(api_client).update_source(id=source, json_patch_operation=[operation])

    except Exception as e:
        print("Exception when calling SourcesApi->update_source: %s\n" % e)

Agreed, I will add a task to fix these patch operations in the documentation.