grokability / jamf2snipe

Import and sync assets from a JAMFPro instance to Snipe-IT asset management.
MIT License
113 stars 55 forks source link

Trailing slash in settings.conf url causes jamf2snipe to fail #94

Closed jocelynkhuu closed 2 years ago

jocelynkhuu commented 2 years ago

Hello! Thanks for creating this tool! I'm new to snipe-it and it's been extremely helpful.

I'm using the main branch and when I first configured settings.conf I had a trailing slash on our jamf pro URL which provided this error when running jamf2snipe as verbose

WARNING:root:Received an invalid status code when trying to retreive JAMF Device list:404 - b'<!doctype html><html lang="en"><head><title>HTTP Status 404 \xe2\x80\x93 Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 \xe2\x80\x93 Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Not Found</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /></body></html>

I wasn't sure what the error meant but once I removed the trailing slash on the url it was able to run without issues. Wondering if the url can be checked for trailing slashes and removed to be a bit more forgiving?

BriskFrost commented 2 years ago

I ran into a similar issue, but with the Snipe-IT URL instead of the Jamf URL. The error provided (see below) initially led me to believe there was an issue with the API key. I eventually figured out it was the trailing slash, but I burned a good 30 minutes chasing my tail with the API key.

ERROR:root:When we tried to retreive a list of models, Snipe-IT responded with error status code:404 - b'{"status":"error","messages":"404 endpoint not found","payload":null}' Snipe models API endpoint failed.

Maybe the quickest and easiest solution to this is updating the documentation. Right now, there is already note in the Configuration - settings.conf section stating "Note: do not add "" or '' around any values." A warning about trailing slashes in the URLs could be added there as well.

snipe commented 2 years ago

@BriskFrost Did you have a trailing slash in your Snipe-IT APP_URL?

BriskFrost commented 2 years ago

Yup, I had https://companyanme.snipe-it.io/ as the URL for our Snipe instance on the settings.config file. Once I removed the slash the error went away.

snipe commented 2 years ago

That's sort of working as expected then? It's in the documentation for Snipe-IT:

Screen Shot 2022-11-16 at 10 17 18 PM
BriskFrost commented 2 years ago

I see, so this is already noted in the API documentation but not in the installation steps of the README.md on Github. I think what led to this issue for @jocelynkhuu and myself is that it isn't mentioned in the README on Github. All the other applicable steps and warnings needed for the installation and operation of jamf2snipe seem to be noted there, but this warning is absent. As I mentioned in my first comment, I think updating the documentation in that section of the README could be beneficial. Either way, it's good to know that the Snipe-IT folks are already aware of this. Thanks for your assistance!

jocelynkhuu commented 2 years ago

Thanks for chiming in here @BriskFrost. I agree that having it in the README.md on Github would be tremendously helpful as I feel that is typically the first place most folks will look. Even just appending it to the Note like suggested above would be helpful. Thanks for all your help!

ParadoxGuitarist commented 2 years ago

In version 1.0.3, there's a new test case that will raise an exit/error if there's a trailing slash for either URL.