Skip to content

Remove requirement for image dimensions in API #17070

Closed
@llamafilm

Description

@llamafilm

NetBox version

v4.0.8

Feature type

Change to existing functionality

Proposed functionality

When uploading an image attachment via API, it should not require image_height and image_width fields. These should be calculated automatically, as they are when uploading using the GUI. Actually this already works, if you provide incorrect values (any integer) they will be ignored, and Netbox figures out the correct dimensions.

As an example, I'd like to use code like this:

files = { 'image': open(filename, 'rb') }
payload = {
    'name': filename,
    'object_id': 454,
    'object_type': 'dcim.site'
}
url = f'{base_url}/api/extras/image-attachments/'
req = requests.post(url, headers=headers, files=files, data=payload)

This currently fails with 400: {"image_height":["This field is required."],"image_width":["This field is required."]}

Use case

Calculating image dimensions requires extra work, and Netbox is already capable of doing this automatically, as it does when you upload using the GUI.

Database changes

none

External dependencies

No response

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions