Invoke datazone create_asset_revision from boto3 , error: Invalid JSON provided

0

Hi all,

I am trying to create an asset revision from boto3 but I always obtain the below error, I follow the boto3 documentation and my code looks good according to the required attributes. I tried to use the AWS CLI and I got the same error.

botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the CreateAssetRevision operation: Invalid JSON provided

I tested other methods like get_domain, get_asset and these worked, this is my current code:

import boto3
import json

client = boto3.client('datazone')

print("Creating revision")

response = client.create_asset_revision(
    description='description from code',
    formsInput=[
        {
            "content": """ 
                {  "summary" : "This description was uploaded from python code.."}
                """,
            "formName": "AssetCommonDetailsForm",
            'typeIdentifier': 'amazon.datazone.RedshiftViewAssetType',
            'typeRevision': '8'
        }
    ],
    domainIdentifier='dzd_xxxxxxxxxxx',
    identifier='yyyyyyyyyyyyyyyy',
    name='table_name'
)

已提问 3 个月前95 查看次数
1 回答
1

The ValidationException with the message Invalid JSON provided could be caused by the JSON content not being properly formatted or containing syntax errors. In this case, the mix of single and double quotes in the content value might be causing confusion in the JSON parsing process.

To resolve this issue, ensure that the JSON content within the content key is properly formatted and uses consistent quoting. Use double quotes " for both the keys and values inside the JSON content, and escape any double quotes that are part of the string values. Here's the corrected formsInput section:

    formsInput=[
        {
            "content": "{\"summary\": \"This description was uploaded from python code.\"}",
            "formName": "AssetCommonDetailsForm",
            "typeIdentifier": "amazon.datazone.RedshiftViewAssetType",
            "typeRevision": "8"
        }
    ],
profile picture
专家
已回答 3 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则