snazy2000 / SnipeitPS

Powershell API Wrapper for Snipe-it
MIT License
181 stars 47 forks source link

Issues with Set-SnipeITAsset #263

Closed Christopheric1 closed 2 years ago

Christopheric1 commented 2 years ago

Context

I am trying to use Set-SnipeITAsset to assign a user to the asset. When trying to do this, it will show the output that "assigned_to" says the ID of the person in the output.

id                               : 547
name                             : 206135-XXXXXX
asset_tag                        : 206135
model_id                         : 61
serial                           : XXXXXXX
purchase_date                    : 2015-09-11 00:00:00
purchase_cost                    : 
order_number                     : 
**assigned_to                      :  116**
notes                            : 
image                            : 
user_id                          : 1
created_at                       : 2022-02-25 09:21:48
updated_at                       : 2022-02-25 10:58:35
physical                         : 1
deleted_at                       : 
status_id                        : 2
archived                         : 0
warranty_months                  : 
depreciate                       : 0
supplier_id                      : 
requestable                      : 0
rtd_location_id                  : 
_snipeit_mac_address_1           : XX;XX;XX;XX;XX
accepted                         : 
last_checkout                    : 
expected_checkin                 : 
company_id                       : 
assigned_type                    : 
last_audit_date                  : 
next_audit_date                  : 
location_id                      : 
checkin_counter                  : 0
checkout_counter                 : 0
requests_counter                 : 0
_snipeit_imei_2                  : 
_snipeit_iccid_3                 : 
_snipeit_meid_4                  : 
_snipeit_mdn_5                   : 
_snipeit_memory_6                : 8GB
_snipeit_cpu_7                   : i5-5300U
_snipeit_cpu_speed_8             : 2.30GHz
_snipeit_eligible_for_upgrade_10 : 
_snipeit_paid_off_11          

When I try to get into the asset to check, I get a 500 internal server error

I run the same command again and I get the same output but with no assigned_to

id                               : 547
name                             : 206135-XXXXXX
asset_tag                        : 206135
model_id                         : 61
serial                           : XXXXXX
purchase_date                    : 2015-09-11 00:00:00
purchase_cost                    : 
order_number                     : 
**assigned_to                      :** 
notes                            : 
image                            : 
user_id                          : 1
created_at                       : 2022-02-25 09:21:48
updated_at                       : 2022-02-25 10:58:35
physical                         : 1
deleted_at                       : 
status_id                        : 2
archived                         : 0
warranty_months                  : 
depreciate                       : 0
supplier_id                      : 
requestable                      : 0
rtd_location_id                  : 
_snipeit_mac_address_1           : XX:XX:XX:XX:XX
accepted                         : 
last_checkout                    : 
expected_checkin                 : 
company_id                       : 
assigned_type                    : 
last_audit_date                  : 
next_audit_date                  : 
location_id                      : 
checkin_counter                  : 0
checkout_counter                 : 0
requests_counter                 : 0
_snipeit_imei_2                  : 
_snipeit_iccid_3                 : 
_snipeit_meid_4                  : 
_snipeit_mdn_5                   : 
_snipeit_memory_6                : 8GB
_snipeit_cpu_7                   : i5-5300U
_snipeit_cpu_speed_8             : 2.30GHz
_snipeit_eligible_for_upgrade_10 : 
_snipeit_paid_off_11             : 

Now it will let me back into the asset, but it is not assigned

Your Environment

Expected Behavior

I was hoping that I could assign the user to the asset and have it show up inside of Snipe-IT

Current Behavior

First thing I get is a 500 internal server error. If I run it again, it no longer shows the person assigned and I can get into the asset again. It is not assigned though.

Steps to Reproduce (for bugs)

  1. Set-SnipeITAsset -id (id of asset) -assigned_to (id of user)
  2. It shows it is updated with that user ID
  3. Try to get into the asset and I got a 500 internal server error
  4. Run the command again and now assigned_to output is blank
  5. Now I can get back into the asset and it is not assigned
PetriAsi commented 2 years ago

I'm not even sure if this have ever worked. As checkout should be done via POST to /hardware/:id/checkout and set-snipeitasset is currently using POST to /hardware/:id/

As workaround you can use Set-SnipeitAssetOwner

Christopheric1 commented 2 years ago

Thanks, I will do that!