JsonDataInvoke

<< Fare clic per visualizzazione il sommario >>

Percorso:  API di piattaforma > Altri servizi > Rest >

JsonDataInvoke

Service

Rest

 

Method

JsonDataInvoke

 

Description

Invokes a REST service by post a key/value pair and returns a dataset containing the fields of the Json structure returned by the REST invocation.

 

Input

Name

Description

Type

Optional

baseUrl

The base url of the REST service (ex.: “https://api.twitter.com/1.1/”).

Required, unless specified in the “BaseUrl” configuration field.

String

 

resource

The resource (ex.: “statuses/show.json”).

Required, unless specified in the “Resource” configuration field.

String

 

parameters

Resource parameters, separated by the & character (ex.: “?id=210462857140252672&trim_user=true”).

Methods ParametersToString, Detokenize or SimpleDetokenize can be used to get this string.

String

 

method

The request method to use to contact the REST resource (“GET”, “POST”, “DELETE”, …).

Defaults to the “Method” configuration field, if specified, otherwise to “GET”.

String

 

contentType

The media type of the request (ex.: “application/x-www-form-urlencoded”, “text/plain”; see http://en.wikipedia.org/wiki/MIME_type).

Defaults to the “ContentType” configuration field, if specified.

String

 

data

A Key/Value pair collection of parameters to post (ex.: "id", "210462857140252672", "trim_user", "true").

Dataset

 

host

The Host header value to use in the HTTP request independent from the request URI; it consists of a hostname and an optional port number (ex.: “www.contoso.com:8080″).

Defaults to the “Host” configuration field, if specified, otherwise it is derived from baseUrl.

String

 

userAgent

The user-agent header value (ex.: “.NET Framework Test Client”).

Defaults to the “UserAgent” configuration field, if specified.

String

 

timeout

The number of milliseconds to wait before the request times out.

Defaults to the “Timeout” configuration field, if specified, otherwise to 100000 (100 seconds).

Int

 

maximumAutomaticRedirections

The maximum number of redirection responses that the request follows; -1 indicates automatic redirections are not allowed.

Defaults to the “MaximumAutomaticRedirections” configuration field, if specified, otherwise to 50.

Int

 

maximumResponseHeadersLength

The maximum allowed length of the response headers, in kilobytes (1024 bytes); a value of -1 means no limit is imposed on the response headers received.

Defaults to the “MaximumResponseHeadersLength” configuration field, if specified, otherwise to 64.

Int

 

headers

Additional headers for the HTTP request; for example, it can contain the “Authorization” header for the “OAuth” authentication (see http://tools.ietf.org/html/rfc5849#section-3.5.1 and http://hueniverse.com/oauth/guide/authentication/). It can also contain the standard headers "Method", "ContentType", "Host", "UserAgent", "Timeout", MaximumAutomaticRedirections", "MaximumResponseHeadersLength" and "Accept", but if there are corresponding parameters with non-null values, they prevail.

Dataset

 

credentialsType

Type of the authentication credentials associated with the request:

1 = None (credentials not required or otherwise specified, maybe through the "Authorization" header)

2 = NetworkCredentials ("userName" and "password" must be specified)

3 = DefaultNetworkCredentials (the network credentials of the current security context)

4 = DefaultCredentials (the system credentials of the application)

5 = BasicAuthentication ("UserName" and "Password" must be specified)

Defaults to the "CredentialsType" configuration field, if specified, otherwise to 1 (None).

Int

 

userName

User name (required if “CredentialsType” = 2 or 5).

Defaults to the “UserName” configuration field, if specified.

String

 

password

Password (required if “CredentialsType” = 2 or 5).

Defaults to the “Password” configuration field, if specified.

String

 

fields

A list containing the names of the first-level fields to return in dataset; a null or empty list implies that all fields are returned.

List of string

 

jsonFieldNames

A list containing the names of fields (regardless of the level) that have to be mapped to the corresponding fields specified in the dictionaryFieldNames list; a null or empty list implies that the field names in the Json structure will be used as keys in the returned dataset.

List of string

 

dictionaryFieldNames

A list containing the names of the dictionary keys corresponding to the field names specified in the jsonFieldNames list; a null or empty list implies that the field names in the Json structure will be used as keys in the returned dataset.

List of string

 

valuesIfNull

A Key/Value pair collection containing values to assign to the specified fields if their returned value is null.

Example: if valuesIfNull contains

“first_name”, “”

“trim_user”, false

the returned Dataset will have

any field named “first_name” (at any level) valued with “” instead of null

and any field named “trim_user” (at any level) valued with false instead of null.

Dataset

 

Output

Name

Description

Type

Optional

returnValue

A Dataset containing the fields of the Json structure returned by the REST invocation.

Dataset

 

 

Remarks

If only the complete url is available (not its baseUrl and resource parts), it can be passed in anyone of the two parameters (baseUrl or resource) leaving the other empty.

The jsonFieldNames and dictionaryFieldNames lists must have the same number of elements. As an example, if jsonFieldNames[0] = "pageid" and dictionaryFieldNames[0] = "PageNumber", the "pageid" field in the Json structure will be returned as the "PageNumber" field in the dataset; fields not present in the jsonFieldNames list will retain their names in the returned dataset.