Fieldcode Manual

Tip: You can use filters for better results

The fcinterface module is a library provided for Fieldcode Interface mapping specific functionalities.

Below are the functions available in the fcinterface module.

fcinterface.stop(message)

Exits the mapping process with the given message and marks the process DONE. Can be used to apply business conditions without blocking the ticket flow.

fcinterface.error(message)

Exits the mapping process with the given error message and marks the process REJECTED. Can be used to handle errors with custom message.

fcinterface.urldecode(value)

Returns the URL decoded value of the given parameter.

fcinterface.urlencode(value)

Returns the URL encoded value of the given parameter.

fcinterface.request(method, url[, authorization=None][, headers=None][, content_type=None][, body=None])

Executes an HTTP(s) request against the given url, using the given method*.
The authorization parameter provides an authorization client to the request**.
The headers parameter takes a dict with custom header key-value pairs.
The content_type parameter can be used in combination with the body to define a payload and its required serialization method***.

*Supported method values: “GET”, “HEAD”, “POST”, “PUT”, “PATCH”, “DELETE”, “OPTIONS”, “TRACE”

**Use the following fcinterface functions to create an authorization client: fcauth, basic_auth, oauth2, api_key, bearer_token

***Supported content_type values:  “NONE”, “FORM_DATA”, “FORM_DATA_URLENCODED”, “RAW_JSON”, “RAW_TEXT” and “RAW_XML”

Authorization client factory functions

fcinterface.fcauth()

Creates an internal Fieldcode authorization client, which can be used to execute internal Fieldcode requests.

fcinterface.basic_auth(username, password)

Creates an Basic Auth client, which uses the given username and password to authorize the request.

fcinterface.oauth2(
    grant_type,
    access_token_url,
    client_authentication,
    client_id
    [, client_secret=None]
    [, username=None]
    [, password=None]
    [, scope=None]
    [, add_auth_data_to=’headers’]
    [, header_prefix=’Bearer ‘]
)

Creates an OAuth2 client, which uses the given parameters to authorize the request.

Supported grant_type values: “PASSWORD”, “CLIENT_CREDENTIALS”

Supported client_authentication values: “BASIC”, “POST”

Supported add_auth_data_to values: “HEADERS”, “URL”

fcinterface.api_key(key, value[, add_auth_data_to=’headers’])

Creates an API key authorization client, which uses the given parameters to authorize the request. The key parameter defines the  name of the header or query parameter (depending on the given add_auth_data_to option), which holds the API key value for the request.

Supported add_auth_data_to values: “HEADERS”, “URL”

fcinterface.bearer_token(token)

Creates a Bearer token authorization client, which uses the given token to authorize the request. 

Request-shortcut functions

fcinterface.get(url[, authorization=None][, headers=None][, content_type=None][, body=None])

Alias for the request function using the “GET” method.

fcinterface.post(url[, authorization=None][, headers=None][, content_type=None][, body=None])

Alias for the request function using the “POST” method.

fcinterface.put(url[, authorization=None][, headers=None][, content_type=None][, body=None])

Alias for the request function using the “PUT” method.

fcinterface.patch(url[, authorization=None][, headers=None][, content_type=None][, body=None])

Alias for the request function using the “PATCH” method.

fcinterface.delete(url[, authorization=None][, headers=None][, content_type=None][, body=None])

Alias for the request function using the “DELETE” method.

fcinterface.apis

A dict of user defined API definition callbacks mapped by the API definition ID. Can be used to execute API calls within the mapping process. The stored API definition callback takes a request payload as argument for execution.

Example usage:
response = fcinterface.apis[‘12345678-90ab-cdef-1234-567890abcdef’](request_payload)

fcinterface.actions

A dict of system defined Action callbacks mapped by the Action ID. Can be used to execute an Action within the mapping process. The stored Action callback takes an action payload as argument for execution.

Example usage:
fcinterface.actions[‘12345678-90ab-cdef-1234-567890abcdef’](action_payload)

Was this topic helpful?
0 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we further improve this topic?
Please provide the reason for your vote. This will help us improve this topic.
Navigation