Skip to content

Inventory ID in body and URL must be the same (ProjectApi.project_project_id_inventory_inventory_id_put) #2

@iukeretarded

Description

@iukeretarded

I'm using this library for a python script, that manages inventories in semaphore. I try to edit inventories based on FreeIPA hostgroups, but i got stuck on ProjectApi.project_project_id_inventory_inventory_id_put_with_http_info and ProjectApi.project_project_id_inventory_inventory_id_put, as i can't get them to work. I obviously dont need both, i just need a way to edit an inventory via API. My code is as follows:

inventory_request = InventoryRequest(
    name=inventory_name,
    project_id=PROJECT_ID,
    type="static-yaml",
    inventory=inventory_content,
    ssh_key_id=SSH_KEY_ID,
    become_key_id=BECOME_KEY_ID,
)

response = ProjectApi(api_client).project_project_id_inventory_inventory_id_put_with_http_info(
    project_id=PROJECT_ID,
    inventory_id=existing_inventory.id,
    inventory=inventory_request,
    _content_type="application/json",
    _host_index=0
)

response = ProjectApi(api_client).project_project_id_inventory_inventory_id_put(
    project_id=PROJECT_ID,
    inventory_id=existing_inventory.id,
    inventory=inventory_request,
    _content_type="application/json",
    _host_index=0
)

In both cases, the error I get is

Full error: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Wed, 21 May 2025 17:48:10 GMT', 'Content-Length': '58'})
HTTP response body: {"error":"Inventory ID in body and URL must be the same"}

Even though i can confirm the inventory_id (existing_inventory.id (1428 in the case)) is correct, and belongs to an inventory im trying to edit.
What might be the issue here? I've seen the thread semaphoreui/semaphore#2338, but i don't really know how can i implement it here.

If more details are needed, please make me know. Im really desperate for a solution.

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