Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Quick way to check if API/URL is valid and can connect. #13

Open
azmcnutt opened this issue Aug 2, 2018 · 1 comment
Open

Comments

@azmcnutt
Copy link

azmcnutt commented Aug 2, 2018

Hi Barry and the group. I was just curious if there was a quick way with SnipeSharp to verify that the API and URL settings are valid, and the server is reachable?

@cofl
Copy link

cofl commented Aug 6, 2018

One quick way would be to submit a junk query, like this:

try
{
    if(snipe.AssetManager.FindAll(new SearchFilter { Limit = 0 }).Total == 0)
    {
        // token is wrong, or URL might be wrong, assuming you have assets in your system.
    }
} catch(JsonReaderException ex)
{
    // base url is really wrong, no idea about the token
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants