Created 06-29-2017 09:04 AM
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()
Created 06-29-2017 10:40 AM
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": [] }
Created 08-03-2017 04:30 PM
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.