Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

I am getting this error "Unable to deserialize JSON " when i am trying to create a new type in Atlas 0.7

Highlighted

I am getting this error "Unable to deserialize JSON " when i am trying to create a new type in Atlas 0.7

New Contributor

I have tried maybe 100 of times with some tweaks but every time i am facing the same error.

u'Unable to deserialize json \\"{\\\\\\"structTypes\\\\\\": [], \\\\\\"traitTypes\\\\\\": [], \\\\\\"classTypes\\\\\\": [{\\\\\\"hierarchicalMetaTypeName\\\\\\": \\\\\\"org.apache.atlas.typesystem.types.ClassType\\\\\\", \\\\\\"superTypes\\\\\\": [], \\\\\\"attributeDefinitions\\\\\\": [{\\\\\\"name\\\\\\": \\\\\\"multiplicityRequired\\\\\\", \\\\\\"reverseAttributeName\\\\\\": \\\\\\"\\\\\\", \\\\\\"multiplicity\\\\\\": \\\\\\"required\\\\\\", \\\\\\"dataTypeName\\\\\\": \\\\\\"string\\\\\\", \\\\\\"isUnique\\\\\\": \\\\\\"true\\\\\\", \\\\\\"isIndexable\\\\\\": \\\\\\"true\\\\\\", \\\\\\"isComposite\\\\\\": \\\\\\"true\\\\\\"}], \\\\\\"typeDescription\\\\\\": \\\\\\"\\\\\\", \\\\\\"typeName\\\\\\": \\\\\\"test\\\\\\"}], \\\\\\"enumTypes\\\\\\": []}\\"'}

I am following this post, here i guess post request is successful. Let me know where i am doing wrong.

https://community.hortonworks.com/articles/124/atlas-api-tips-create-trait-type-example.html

curl Command :

curl -u atlas_user:password  -H 'Content-Type: application/json;  charset=UTF-8' -X POST -d '{"enumTypes": [],"structTypes": [],"traitTypes": [{"superTypes":[],"hierarchicalMetaTypeName":"org.apache.atlas.typesystem.types.TraitType","typeName": "EXPIRES_ON", "attributeDefinitions":[{ "name": "expiry_date", "dataTypeName": "date", "multiplicity": "required","isComposite": false,"isUnique": false,"isIndexable": true,"reverseAttributeName": null}]}],"classTypes": []}' http://hostname:21000/api/atlas/types


I am attaching my python code as well for reference.

import requests
import json


hostname = 'hostname:21000'
headers = {'Content-Type': 'application/json;  charset=UTF-8'}
atlas_user_name = 'username'
atlas_password = 'password'


create_type ={  
  "enumTypes": [],  
  "structTypes": [],  
  "traitTypes": [  
    {  
      "superTypes":[], 
      "hierarchicalMetaTypeName":
      "org.apache.atlas.typesystem.types.TraitType",   
      "typeName": "EXPIRES_ON", 
      "attributeDefinitions": [  
        { 
          "name": "expiry_date", 
          "dataTypeName": "date", 
          "multiplicity": "required", 
          "isComposite": "false", 
          "isUnique": "false", 
          "isIndexable": "true", 
          "reverseAttributeName": ""  
        }  
      ]  
    } 
  ],  
  "classTypes": []
}

type_create_post = requests.post(hostname+ '/api/atlas/types' , headers=headers,data = json.dumps(create_type),auth =(atlas_user_name,atlas_password))


print type_create_post.json()









entity_create_post = requests.post(hostname+ '/api/atlas/types' , headers=headers,data = json.dumps(create_entity),auth =(atlas_user_name,atlas_password))


print entity_create_post.json()
2 REPLIES 2

Re: I am getting this error "Unable to deserialize JSON " when i am trying to create a new type in Atlas 0.7

Expert Contributor

@subash sharma

Try this :

1. Changed "" to None

2.Changed String false , true to boolean True ,False

3. Added typeDescription and typeVersion

create_type = {
    "enumTypes": [],
    "structTypes": [],
    "traitTypes": [
        {
            "superTypes": [],
            "hierarchicalMetaTypeName":
                "org.apache.atlas.typesystem.types.TraitType",
            "typeName": "EXPIRES_ON",
            "typeDescription": None,
            "typeVersion": "1.0",
            "attributeDefinitions": [
                {
                    "name": "expiry_date",
                    "dataTypeName": "date",
                    "multiplicity": "required",
                    "isComposite": False,
                    "isUnique":False,
                    "isIndexable": True,
                    "reverseAttributeName": None}
            ]
        }
    ],
    "classTypes": []
}

Re: I am getting this error "Unable to deserialize JSON " when i am trying to create a new type in Atlas 0.7

New Contributor

Hi, pls see for the solution at https://issues.apache.org/jira/browse/ATLAS-396

"Creating an entity with non-existing type results in "Unable to deserialize json" error " is the actual cause of this error.