Jump to content

500 error when updating custom field for a few devices


ttl

Recommended Posts

This doesn't happen with every device, but only some of them.

Is there anywhere to look on Filewave's side to see what would cause the custom field update to issue a 500 response?

 

Here's the component that works for virtually every device in Filewave, short of a small handful:

# update the custom field using the device id
api = filewave + 'inv/api/v1/client/' + device_id

params = {
    "CustomFields": {
        "customfield_one": {
            "exitCode": 0,
            "status": 0,
            "updateTime": datetime.now().isoformat(),
            "value": value_one
        },
        "customfield_two": {
            "exitCode": 0,
            "status": 0,
            "updateTime": datetime.now().isoformat(),
            "value": value_two
        },
        "customfield_three": {
            "exitCode": 0,
            "status": 0,
            "updateTime": datetime.now().isoformat(),
            "value": value_three
        }
    }
}

params = json.dumps(params)

update_fields = requests.patch(api, params, headers=headers, timeout=2)

 

Link to comment
Share on other sites

  • Moderators

I forget the error code but for the field is it one that is assigned to the devices that you are trying to use that with? So a field can either be assigned to all devices or can be selectively assigned to devices. If the field isn't assigned to a specific device at all then I know an error is thrown but I don't remember if it's that. One other thing that can throw errors if you usually see your code work but just once in a while it doesn't work could be that every 10 minutes (by default) the server recalculates Smart Groups and when it is doing that it will reject things in those seconds that it could be processing so having some retry would make sense to handle that. 

Link to comment
Share on other sites

Assigned to all devices.

 

I started logging these and having a report email me everytime these are triggered, seems to be the same devices everytime.  No similarity between them I can ascertain.

I have a script that runs on a cron every 30 minutes that hooks into this system and bring data back to Filewave, I'll adjust the time slightly in case it is hitting the smart group recalculation, thanks!

Link to comment
Share on other sites

  • Moderators

What is running this script?  How are you determining the device_id?

Have you considered sending details to a log file from the script?  For example:

print(api)

Link to comment
Share on other sites

It's a python script running on a rendezvous server used for small jobs with APIs.

device_id is obtained from: filewave.example.com/api/inv/api/v1/query_result/123

 

This ended up being a programming bug on my part, something like this was coming from Snipe It:

value_three = snipeit['expected_checkin']

 

But Snipe It was sending it in json format:

{'date': '2024-05-02', 'formatted': '2024-05-02'}
 

So value_three should have been:

value_three = snipeit['expected_checkin']['date']

 

Devices that previously triggered a 500 now appear to be updating successfully. (The query numbers are different on each refresh, which is expected with the change in data)

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...