0

I am trying to insert set of classifications or tags into Apache Atlas using API. I am facing an error.

Can any one help me any roundabouts of overcoming this error and insert the classifications. My code:


import requests
import json
from requests.auth import HTTPBasicAuth
#specify url
url = 'http://aaaaa/api/atlas/v2/entity/classification'
print(url)
bulk = { "classification":{ "typeName":"Confidential","attributes":{ "retention_required":"true","max_retention_time_months":"12"}},"entityGuids":[ "be532571-1663-4550-af6d-28cfe39769f6"]}

#Call REST API
response = requests.put(url, data=bulk,auth=HTTPBasicAuth('xxx', 'yyy'))
print(response)
print(response.text)

This GUID is valid.

The error I face is :

<Response [500]>
There was an error processing your request. It has been logged (ID 7e31c72f5e0f5e3b).

In short, I want to achieve the given screen functionality thru python.

enter image description here

Thank you.

usr_lal123
  • 650
  • 12
  • 28

1 Answers1

0

Send request to: http://aaaaa/api/atlas/v2/types/typedefs

You should use post if the classification doesn't exist already, if the classification exists, you will get 409 Client Error. Use PUT to update existing classification.

Your json should look something like this:

{'classificationDefs: [{
            'entityTypes': entityTypes,
            'subTypes': subTypes,
            'superTypes': superTypes,
            'attributeDefs': attributeDefs,
            'category': category,
            'createdBy': createdBy,
            'description': description,
            'name': name,
            'options': options,
            'typeVersion': typeVersion,
            'updatedBy': updatedBy,
            'version': version
        }]
}

Types of attributes in json:

list: entityTypes, attributeDefs, superTypes, subTypes

dictionary: options

number: version

rest is of type string or text