Support Questions

Find answers, ask questions, and share your expertise

Error while creating Atlas trait via rest api call

avatar

atlas-error.txtcreatetag.txt

Hi Team,

Hope you can help me out. I am using Atlas API to get the list of traits and create traits via API calls.

I am able to call the GET method without any issues. But when I call the POST method it gives an error as shown below:

Error - Unable to deserialize json

Below are the commands that I am executing:

Get All tags ---------------- Works fine

curl --user admin:admin -H "Content-Type: application/json" -X GET "http://ServerName:Port/api/atlas/types?type=TRAIT"

Create tag ----------------- Gives Error

curl --user "admin:admin" -H "Content-Type: application/json" -d "createtag.txt" -X POST "http://ServerName:Port/api/atlas/types"

1 ACCEPTED SOLUTION

avatar
Master Guru

Please try this json

{
 "enumTypes":[],
 "structTypes":[],
 "traitTypes":[
 {
 "superTypes":[],
 "hierarchicalMetaTypeName":"org.apache.atlas.typesystem.types.TraitType",
 "typeName":"NAME_OF_TAG_TO_CREATE",
 "typeDescription":null,
 "attributeDefinitions":[]
 }

View solution in original post

6 REPLIES 6

avatar
Master Guru

Please try this json

{
 "enumTypes":[],
 "structTypes":[],
 "traitTypes":[
 {
 "superTypes":[],
 "hierarchicalMetaTypeName":"org.apache.atlas.typesystem.types.TraitType",
 "typeName":"NAME_OF_TAG_TO_CREATE",
 "typeDescription":null,
 "attributeDefinitions":[]
 }

avatar

Hi Sunile,

I tried the json you provided, but still am getting the same error.

avatar
Master Guru

here is example where my.json has content from above

curl -X POST -d @my.json -u admin:admin -H 'Content-Type: application/json;  charset=UTF-8' 127.0.0.1:21000/api/atlas/types

more examples here

https://github.com/sunileman/Atlas-API-Examples

avatar
Super Collaborator

Hi @Jigar Chhadwa , provide createtag.txt as @createtag.txt . In your case,curl command took "createtag.txt" itself as the json instead of the content in the file.

Example :

curl --user "admin:admin" -H "Content-Type: application/json" -d @createtag.txt -X POST "http://ServerName:Port/api/atlas/types"

avatar

createtag.txtatlas-api-call-and-error.txtGot it @Sharmadha Sainath , I tried with the new command but got the same error as before. I changed the name of the tag and the description. Also since GET is working fine, I got the definition from one of the tags which is already created from the UI, so the definition seems to be the correct one.

avatar

This was resolved with the corrected json input. the description column was missing.

thanks all