Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

Calling a command via HTTP GET means:

  • Sets Set all request parameterscommand parameters.

  • Sets Set the command body to null.

Here is an example to execute the log command as HTTP GET request, and set its message parameter to a string value using a HTTP request parameter:

...

Info

Calling a command via HTTP POST (default behaviour) means:

  • Sets Set all request parameterscommand parameters.

  • Sets Set the request bodycommand input body.

    • If Content-Type is application/json or text/plain: The parsed JSON or plain text is set into the body and can be directly accessed by PELof the command.

    • If Content-Type is multipart/form-data, then each part with name file will be processed into a content object and provided as content collection to the command.

    • Otherwise, the body is provided as single content object to the command which can be resolved and read on a later step.

Since

Status
colourBlue
titleVersion 10
: When passing the optional request parameter ?params=body:

  • If the request body contains a JSON or YAML → This will be applied as command parameters.

  • Sets Set the command body to null.

Here is an example to execute a single command as HTTP POST request, and set the message parameter to a log command using a HTTP POST data body in curl:

...

Executing a Pipeline

Execute by HTTP request

Executing a Pipeline with HTTP is simple:

  1. Create the Pipeline YAML script

  2. Upload this YAML script in a HTTP POST request to the server

The server then executes your Pipeline and returns with the final output message.

As an example let's assume a more sophisticated pipeline like this, with different parameter value formats:

Code Block
pipeline:
 - drive.read:
     path: /my.pdf
 - pdf.stamp:
      text: |
        Hello World!
 - drive.save:
     path: '/my-stamped.pdf'

You can execute a pipeline via HTTP request. Also see the Pipeline API docs: https://pipeforce.github.io/redoc.html#tag/Pipeline-API

Ad-hoc pipeline

Executing an ad-hoc pipeline (ad-hoc = not persisted) with HTTP requires these steps:

  1. Set the pipeline YAML script in the body of a request

  2. Set the Content-Type header of the request to

    1. application/yaml if the body is a single YAML pipeline or to

    2. multipart/form-data if the body contains a YAML pipeline and additional files to be uploaded and to be provided as content collection to the body of the pipeline. In the multipart request body, the pipeline part must have the name pipeline and each file part must have the name file.

  3. Send this request as HTTP POST to the server at /api/v3/pipeline

The server then executes the pipeline and returns with the final body message of the pipeline as response body.

Here is an example, with a YAML pipeline in the body. This example loads a PDF file, sets a text on it and stores it back. In order to execute this Pipeline YAMLpipeline, you can send it to the server using curl for example:

Code Block
curl -X POST "https://hub-ns.pipeforce.net/api/v3/pipeline" \
  -H "Content-Type: application/yaml" \
  -u "username:password" \
  --data-binary @- << EOF
pipeline:
 - drive.read:
     path: /my.pdf
 - pdf.stamp:
     text: "Hello World!"
 - drive.save:
     path: /my-stamped.pdf
EOF

NOTESummary

  • The HTTP endpoint must be /api/v3/pipeline

  • The HTTP method must be POST

  • The HTTP header Content-Type must be application/yaml or multipart/form-data

When using cURL, the EOF syntax is required here in order to preserve the intends of the YAML script. Optionally, you can write the YAML in a local file an pass this file as argument for the body. See the example below, where the pipeline is specified in a file with name mypipeline.yaml:

...

See HTTP Execution Reference for an summary of all supported HTTP options.

Sending the Body Message with HTTP

You can also send the pipeline body in an HTTP request. See this example:

Code Block
pipeline:
  - log:
      message: "BODY: #{body.text}"

body: {"text": "Hello World!"}

Note that the value of the body can be a primitive or a JSON without additional escaping required.

...

Persisted pipeline

In order to execute a pipeline which is persisted in the property store, send a HTTP POST to the /pipeline:{path} endpoint whereas {path} is the path of the pipeline to be executed.

The body of the request becomes the body to the pipeline.

The request parameters become the variables to the pipeline.

Example:

Code Block
curl -X POST "https://hub-ns..pipeforce.net/api/v3/pipeline" \
  -H "Content-Type: application/yaml" \
  -u "username:password" \
  --data-binary @- << EOF
pipeline:
  - log:
      message: "BODY: #{body.text}"

body: {"text": "Hello World!"}
EOF

The log output will be:

Code Block
BODY: Hello World!:global/app/myapp/pipeline/mypipeline" \
  -u "username:password"

This executes the pipeline stored at path global/app/myapp/pipeline/mypipeline in the property store and returns the final pipeline body as response body to the caller.

Execute in Portal

The portal offers an advanced online editor with syntax highlighting, code completion and debugging support, where you can write pipelines and execute them online. This is the easiest and most preferred way to ad-hoc execute and test your pipelines. Here you can see a simple pipeline after its ad-hoc execution in the online editor:

...