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'
)

asked 4 months ago134 views
1 Answer
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
EXPERT
answered 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions