Search

User Manual

GETTING STARTED


MODULES AND PLATFORM


APPENDIX


TUTORIALS & HELPFUL TRICKS


GLOSSARY


STRATEGIC PARTNER LINKS

Sepasoft - MES Modules
Cirrus Link - MQTT Modules

RESOURCES

Inductive University
Ignition Demo Project
Knowledge Base Articles
Forum
IA Support
SDK Documentation
SDK Examples

ALL MANUAL VERSIONS

Ignition 8.1
Ignition 7.9
Ignition 7.8

Deprecated Pages

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »


This function is used in Python Scripting.

Description

Provides a general use object that can be used to send and receive RESTful HTTP requests. The object created by this function is a wrapper around Java's HttpClient class. Typical use involves creating the a JythonHttpClient object with a call to system.net.httpClient, and then utilizing the varous methods (get(), post(), etc) on the JythonHttpClient to handle requests.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.net.httpClient()

  • Parameters

Integer timeout - A value, in milliseconds, to set the client’s connect timeout setting to. [Optional - Defaults to 60000]

Boolean bypass_cert_validation - A value, in milliseconds, to set the client’s read timeout setting to. [Optional - Defaults to False]

String username - A string indicating the username to use for authentication if the remote server requests authentication; specifically, by responding with a WWW-Authenticate or Proxy-Authenticate header. Only supports Basic authorization. If username is present but not password, an empty string will be used for password. [Optional - Defaults to None]

String password - A string indicating the password to use for authentication. [Optional - Defaults to None]

String proxy - The address of a proxy, which will be used for HTTP and HTTPS traffic. If the port is not specified, it will be assumed from the protocol in the URL, i.e. 80/443. [Optional - Defaults to None]

String cookie_policy - A string representing this client’s cookie policy. Accepts values "ACCEPT_ALL", "ACCEPT_NONE", and "ACCEPT_ORIGINAL_SERVER" . [Defaults to "ACCEPT_ORIGINAL_SERVER"]

String redirect_policy - A string representing this client’s redirect policy. Acceptable values are listed below. [Optional - Defaults to "Normal"]

                    • "NEVER" - never allow redirects
                    • "ALWAYS" - allow redirects,
                    • "NORMAL" - allows redirects, except those that would downgrade to insecure addresses (i.e., HTTPS redirecting to HTTP).

Callable customizer - A reference to a callable function. This function will be called with one argument (an instance of HttpClient.Builder). The function should operate on the builder class and allows for arbitrary customization of the created HTTP client. [Optional - Defaults to None]

  • Returns

JythonHttpClient  -  An object wrapped around an instance of Java's HttpClient class. The client object has methods that can be called against a website to get or send information through the web. See the panel below for more details.

  • Scope

Gateway, Vision Client, Perspective Session

JythonHttpClient

Once a JythonHttpClient object has been created, HTTP calls can be made with the build in methods detailed below. The various methods available on this object can be split under different categories.

Methods

 Synchronous (Blocking) Calls

This section details synchronous methods. Each method in this section returns a Response object.

Methods

The following methods return a Response object. Parameters for these functions are documented below.

MethodDescriptionReturn type
.get()makes an HTTP GET call, blocking for a responseResponse
.getAsync()makes an HTTP GET call without blocking.Promise
.post()makes an HTTP POST call, blocking for a responseResponse
.postAsync()makes an HTTP POST call without blocking. Promise
.put()makes an HTTP PUT call, blocking for a responseResponse
.putAsync()makes an HTTP PUT call without blocking. Promise
.delete()makes an HTTP DELETE call, blocking for a responseResponse
.deleteAsync()makes an HTTP DELETE call without blocking. Promise
.patch()makes an HTTP PATCH call, blocking for a responseResponse
.patchAsync()makes an HTTP PATCH call without blocking. Promise
.head()Sets the header on the JythonHttpClient object, blocking until the header has been set.Response
.headAsync()
Promise
.options()
Response
.optionsAsync()
Promise
.trace()
Response
.traceAsync()
Promise
.request()
Response
.requestAsync()
Promise


  • .get()
  • .post()
  • .put()
  • .delete()
  • .head()
  • .patch()
  • .options()
  • .trace()
  • .request()


Parameters

Parameters in this section can be used by any of the methods above. Exceptions to this rule will be defined on each parameter.

String url - The URL to connect to. [Required]

String method - The method to use in the request. [Required - used by .request() only]

String or Dictionary parameters - Parameters to append to the URL. [Optional - Defaults to None]

          • If supplied as a string, will be directly appended to the URL.
          • If supplied as a dictionary, key/value pairs will be automatically URL encoded.

String or Dictionary or byte[] - Data to send in the request. [Optional - Defaults to None]

            • String data will be sent with a Context-Type of "text/plain; charset=UTF-8", unless the Content-Type header was already specified
            • Dictionary data will be automatically encoded into JSON. The Content-Type header will be set to "application/json;charset=UTF-8" unless the Content-Type header was already specified.
            • Byte arrays will be sent directly, and set the Content-Type header to application/octet-stream unless the Content-Type header was already specified.

String file - The path to a file relative to the HTTP client. If specified, and the path is valid, will directly send the data in the file. The file attribute overrides any value set in data; only the file’s data will be sent.[Optional - Defaults to None]

Dictionary headers - A dictionary of headers to add to the request. [Optional - Defaults to None]

String username - Username to add to a Basic Authorization header in the outgoing request. If username is specified, but not password, password is assumed to be an empty string. [Optional - Defaults to None]

String password - Password to add to a Basic Authorization header in the outgoing request. [Optional - Defaults to None]

Integer timeout - Timeout for this request, in milliseconds. [Optional - Defaults to 60000]

 Asynchronous (Non-Blocking) Calls

This section details synchronous methods. Each method in this section returns a Promise object.

Methods

The following methods return a Promise object. Parameters for these functions are documented below.

  • .getAsync()
  • .postAsync()
  • .putAsync()
  • .deleteAsync()
  • .headAsync()
  • .patchAsync()
  • .optionsAsync()
  • .traceAsync()
  • .requestAsync()


Parameters

Parameters in this section can be used by any of the methods above. Exceptions to this rule will be defined on each parameter.

String url - The URL to connect to. [Required]

String method - The method to use in the request. [Required - used by .requestAsync() only]

String or Dictionary parameters - Parameters to append to the URL. [Optional - Defaults to None]

          • If supplied as a string, will be directly appended to the URL.
          • If supplied as a dictionary, key/value pairs will be automatically URL encoded.


String or Dictionary or byte[] - Data to send in the request. [Optional - Defaults to None]

            • String data will be sent with a Context-Type of "text/plain; charset=UTF-8", unless the Content-Type header was already specified
            • Dictionary data will be automatically encoded into JSON. The Content-Type header will be set to "application/json;charset=UTF-8" unless the Content-Type header was already specified.
            • Byte arrays will be sent directly, and set the Content-Type header to application/octet-stream unless the Content-Type header was already specified.

String file - The path to a file relative to the HTTP client. If specified, and the path is valid, will directly send the data in the file. The file attribute overrides any value set in data; only the file’s data will be sent.[Optional - Defaults to None]

Dictionary headers - A dictionary of headers to add to the request. [Optional - Defaults to None]

String username - Username to add to a Basic Authorization header in the outgoing request. If username is specified, but not password, password is assumed to be an empty string. [Optional - Defaults to None]

String password - Password to add to a Basic Authorization header in the outgoing request. [Optional - Defaults to None]

Integer timeout - Timeout for this request, in milliseconds. [Optional - Defaults to 60000]


 Response

This section details methods and attributes of the Response object. This object is created with the various synchronous functions listened elsewhere on the page.

Methods

The following methods return a Response object. Parameters for these functions are documented below.

  • .foo()

Attributes

Bar

 Promise

This section details methods and attributes of the Promise object. This object is created with the various asynchronous functions listened elsewhere on the page.

Methods

The following methods return a Response object. Parameters for these functions are documented below.

  • .foo()

Attributes

Bar


Code Examples
Code Snippet
 
Code Snippet
 
  • No labels