Skip to content

put.elements - json data issues #46

@fabiano-lima

Description

@fabiano-lima

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.\""
    }

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions