service

Modified on Thu, 9 Jul at 10:50 AM

service

TABLE OF CONTENTS

Fetch information from an external service

Definition

any service(string $service, string $operation, any $data)

Fetches information from a connected service. The service needs to first be defined under Connected services.

Parameters

string $service

Name of the service.

string $operation

Name of the operation.

any $data

Data to send.

Returns

any

The response body of an external service.

Examples

The setup of the external service is relevant here as well:

Sample data
{
  "post": {
    "id": "3"
  }
}
Transformation
{
    a: service('ExampleService', 'getByID', {
        id: post.id
    }),
    b: service('ExampleService', 'postToDirectory', {
        "directory": 'posts',
        "userId": `7`,
        "title": 'ExampleTitle',
        "body": 'ExampleText'
    })
}
Result
{
  "a": {
    "userId": 1,
    "id": 3,
    "title": "ea molestias quasi exercitationem repellat qui ipsa sit aut",
    "body": "et iusto sed quo iure\nvoluptatem occaecati omnis eligendi aut ad\nvoluptatem doloribus vel accusantiu... (TRUNCATED)"
  },
  "b": {
    "userId": 7,
    "title": "ExampleTitle",
    "body": "ExampleText",
    "id": 101
  }
}

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article