API via PyNetBox will process GET but not POST (create)
My code is as seen below. This initial block will print the correct information so I know my API connection is working (and the API token, not shown, has Write permissions enabled within the web interface). However, the attempt to create a new device entry passes with a <200> code, but the print result is just blank. There is also no change in the web interface to reflect the creation of the device through this script. Using version 4.2.2 of NetBox with the newest version of PyNetBox. Any assistance would be greatly appreciated, thanks!
EDIT: Thanks to user TyphonVirtus for suggesting that POST requests require your NetBox URL to be pointed to HTTPS instead of just HTTP. This solved my issue! Thank you to everyone who took the time to leave a helpful comment!
#----------------------------------------------------------------
# Get Specific VM by ID
#----------------------------------------------------------------
vmID = 2069
vm = nb.virtualization.virtual_machines.get(id=vmID)
print(f"Virtual Machine - {vm}")
print(f"VM NetBox ID - {vm.id}")
print(f"VM NetBox Serial # - {vm.serial}")
print(f"Primary IPv4 - {vm.primary_ip4}")
#--------------------------------------------------------
# Create new Device entry
#--------------------------------------------------------
new_device = nb.dcim.devices.create(
name='new-test-device',
device_type='1',
site='1',
device_role='1',
status='active'
)
print(new_device)