Class HTTP


  • public class HTTP
    extends Object
    This class provides static methods that can be used in automation rules for sending HTTP requests
    Author:
    Kai Kreuzer - Initial contribution
    • Field Detail

      • CONTENT_TYPE_JSON

        public static final String CONTENT_TYPE_JSON
        Constant which represents the content type application/json
        See Also:
        Constant Field Values
    • Constructor Detail

      • HTTP

        public HTTP()
    • Method Detail

      • sendHttpGetRequest

        public static String sendHttpGetRequest​(String url)
        Send out a GET-HTTP request. Errors will be logged, returned values just ignored.
        Parameters:
        url - the URL to be used for the GET request.
        Returns:
        the response body or NULL when the request went wrong
      • sendHttpPutRequest

        public static String sendHttpPutRequest​(String url)
        Send out a PUT-HTTP request. Errors will be logged, returned values just ignored.
        Parameters:
        url - the URL to be used for the PUT request.
        Returns:
        the response body or NULL when the request went wrong
      • sendHttpPutRequest

        public static String sendHttpPutRequest​(String url,
                                                String contentType,
                                                String content)
        Send out a PUT-HTTP request. Errors will be logged, returned values just ignored.
        Parameters:
        url - the URL to be used for the PUT request.
        contentType - the content type of the given content
        content - the content to be send to the given url or null if no content should be send.
        Returns:
        the response body or NULL when the request went wrong
      • sendHttpPostRequest

        public static String sendHttpPostRequest​(String url)
        Send out a POST-HTTP request. Errors will be logged, returned values just ignored.
        Parameters:
        url - the URL to be used for the POST request.
        Returns:
        the response body or NULL when the request went wrong
      • sendHttpPostRequest

        public static String sendHttpPostRequest​(String url,
                                                 String contentType,
                                                 String content)
        Send out a POST-HTTP request. Errors will be logged, returned values just ignored.
        Parameters:
        url - the URL to be used for the POST request.
        contentType - the content type of the given content
        content - the content to be send to the given url or null if no content should be send.
        Returns:
        the response body or NULL when the request went wrong
      • sendHttpDeleteRequest

        public static String sendHttpDeleteRequest​(String url)
        Send out a DELETE-HTTP request. Errors will be logged, returned values just ignored.
        Parameters:
        url - the URL to be used for the DELETE request.
        Returns:
        the response body or NULL when the request went wrong