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

gefragt vor 3 Monaten108 Aufrufe
1 Antwort
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
EXPERTE
beantwortet vor 3 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen