CloudGenix / sdk-python

Python2 and Python3 SDK for the CloudGenix AppFabric
MIT License
25 stars 11 forks source link

put.elements - json data issues #46

Open fabiano-lima opened 6 months ago

fabiano-lima commented 6 months ago

Having issues when trying to update an element, I´m following the documentation, including the examples, also postman´s.

By the way, the requirement is to associate an element to a site_id, that is the only change needed, is this the correct endpoint ?

def get_elements(cgx_session, element_id):
    response = cgx_session.get.elements(element_id=element_id)
    if response.cgx_status:
        return response.cgx_content

def update_elements(cgx_session, element_id, json_data, tenant_id):
    response = cgx_session.put.elements(element_id=element_id, data=json_data, tenant_id=tenant_id)
    if response.cgx_status:
        print (json.dumps(response.cgx_content, indent=4))

site_id="12345"
element_id = "54321"
tenant_id = "111111"

json_data= get_elements(cgx_session, element_id)

#json_data["description"] = "test_via_api_now"
json_data["site_id"] = "12345"   ############ This is the only change required for now to have the element associated to this site_id

print ('*****************************')
update_elements(cgx_session, element_id, json_data, tenant_id)`

Get function woks OK, issue is with Update function:

"_error": [
    {
        "code": "INVALID_JSON_EXTRA_ATTRIBUTE",
        "message": "\"Input JSON has attribute not recognized by the current schema.\""
    }

Trying also using the json example from site and only changing the correspondent ids, this is the error:

"_error": [
    {
        "code": "INVALID_JSON_INPUT",
        "message": "\"Input JSON does not have all required attributes.\""
    }

`

fabiano-lima commented 5 months ago

appreciate if could get support. Thank you!