Skip to content

Troubleshoot the Guardian API

The Guardian API can be used to automate a variety of processes and give you a greater deal of flexibility when monitoring your data. The following topic describes how use the Guardian API.

Save Requests

If you are planning to use the Guardian API for development work or for an extended period of time, using an application such as Postman can save you time by saving queries, formatting and presenting JSON responses.

HTTP Code Status

The following table outlines the common HTTP codes received via the Guardian API, what status they indicate, and their meaning.

Code Status Description
200 OK Everything worked as expected.
201 Created A new record was successfully created after a POST request.
204 No Content A record was successfully updated after a PUT request.
400 Bad Request Submitting malformed JSON or bad syntax.
401 Unauthorized No valid API key was provided.
403 Forbidden Parameters were valid but the request failed due to lack of permissions. For example, requesting to view details of a node that you do not have access to.
422 Unprocessable Entity The request is logically incorrect - often missing a required parameter. For example, no policy_id provided when requesting a list of policy versions.
500-504 Server Errors Server errors.

Ignore Self-Signed Certificates

If your appliance is using a self-signed certificate, you may need to implicitly trust the server before making an API request. The following section describes how to ignore the self-signed certificate for all web requests by adding an option to the script that corresponds to the programming language used.

cURL

To ignore SSL certificate checks for cURL, add the -k option to your script.

PowerShell

To ignore SSL certificate checks for PowerShell, add the -type @ option to your script. For example:

add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

Ruby

To ignore SSL certificate checks for HTTParty, add the :verify => false option. For example:

response = HTTParty.get(url, :headers => <auth_headers>, :verify => false)

Python

To ignore SSL certificate checks when using the Python requests library, append verify=False as an option on all requests. For example:

response = requests.get(url, headers=headers, verify=False)

GoLang

To ignore SSL certificate checks when using the default HTTP package in GoLang, disable all SSL checks before running any API calls by using the following line of code:

http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{ InsecureSkipVerify: true }

Ruby SDK

To ignore SSL certificate checks when using the Ruby SDK, the optional 4th parameter of the Account constructor allows you to ignore SSL certificate checks (defaults to false if omitted). For example:

o = UpGuard::Account.new("https://me.cloudhouse.com", "api_key", "sec_key", true)

Python SDK

To ignore SSL certificate checks when using the Python SDK, the optional 4th parameter of the Account constructor allows you to ignore SSL certificate checks (defaults to false if omitted). For example:

o = upguard.Account("https://me.cloudhouse.com", "api_key", "sec_key", True)

Note: The Python and Ruby SDKs are currently invite-only. Please email helpdesk@cloudhouse.com if you are interested in helping us test with your use case.