Skip to content

SendRequest

SendRequest action is used to send a request to a REST service.

The properties defined in Action are also applicable to this action.

SendRequest Properties

Property Type Required
Target RestServiceTarget Required
_Type const Required

Target


_Type

  • type: const

The value of this property must be equal to:

"Action.Type.RestService.SendRequest"

Action Result

The ActionResult of this action is a JS primitive type, object or a JS array.


Examples

Get portion of response json object

{
  "_Type": "Action.Type.RestService.SendRequest",
  "Target": {
    "Path": "/Groups",
    "RequestProperties": {
      "Method": "GET",
      "Headers": {
        "Accept": "application/json"
      }
    },
    "OutputPath": "/d/results",
    "Service": "/MyMDKApp/Services/MyRest.service"
  },
}      

Assume below is the response data in JSON format. If the OutputPath property value is set to '/d/results'. This means that you only want the data in 'd.results'.

{
  "d":
    {
      "results":[
        {
          "Id":"Hu5PfmXDuNbUoKapf1EZFh",
          "Name":"GroupKrishna"
        },
        {
          "Id":"PX6qrsTU1BrCmyAJWzdXGl",
          "Name":"GroupVelidi"
        },
      ]
    }
}

Post using native data

A HTTPS POST request is sent with native data of file. The header['Content-Type'] should be set according to content of file.

{
  "_Type": "Action.Type.RestService.SendRequest",
  "Target": {
    "Path": "/Images",
    "RequestProperties": {
      "Method": "POST",
      "Headers": {
        "Content-Type": "#Control:Attachment/#Value/#Index:0/contentType"
      },
      "Body": "#Control:Attachment/#Value/#Index:0/content"
    },
    "Service": "/MyMDKApp/Services/MyRest.service"
  }
}

Post using json object or array

A HTTPS POST request is sent with the request body as JSON string. The header['Content-Type'] is set to application/json by default.

{
  "_Type": "Action.Type.RestService.SendRequest",
  "Target": {
    "Path": "/Customers",
    "RequestProperties": {
      "Method": "POST",
      "Body": {
        "Address": "{#Control:Address/#Value}",
        "City": "{#Control:City/#Value}",
        "CompanyName": "{#Control:CompanyName/#Value}",
        "ContactName": "{#Control:ContactName/#Value}",
        "ContactTitle": "{#Control:ContactTitle/#Value}",
        "Country": "{#Control:Country/#Value}",
        "Fax": "{#Control:Fax/#Value}",
        "Phone": "{#Control:Phone/#Value}",
        "PostalCode":"{#Control:PostalCode/#Value}",
        "Region":"{#Control:Region/#Value}"
      }
    },
    "Service": "/MyMDKApp/Services/MyRest.service"
  }
}
{
  "_Type": "Action.Type.RestService.SendRequest",
  "Target": {
    "Path": "/asset/imports/123/files",
    "RequestProperties": {
      "Method": "POST",
      "Body": [
        {
          "Id": "{#Control:Id/#Value}",
          "Name": "{#Control:Name/#Value}",
          "AssetName": "{#Control:AssetName/#Value}"
        },
        {
          "Id": "{#Control:Id2/#Value}",
          "Name": "{#Control:Name2/#Value}",
          "AssetName": "{#Control:AssetName2/#Value}"
        }
      ]
    },
    "Service": "/MyMDKApp/Services/MyRest.service"
  }
}

Post using form data

A HTTPS POST request is sent with the request body specially formatted as a series of "parts", separated with MIME boundaries. The header['Content-Type'] should be set to multipart/form-data.

{
  "_Type": "Action.Type.RestService.SendRequest",
  "Target": {
    "Path": "/api/v2/similarity-scoring",
    "RequestProperties": {
      "Method": "POST",
      "Headers": {
        "Content-Type": "multipart/form-data"
      },
      "Body": [
        {
          "Key": "files",
          "Value": "#Control:Attachment/#Value/#Index:0"
        },
        {
          "Key": "options",
          "Value": "#Control:Options/#Value"
        }
      ]
    },
    "Service": "/MyMDKApp/Services/MyRest.service"
  }
}