Webservice Functions¶
ValueFromJPath Function¶
Description
Returns a value from JSON, using the JPath syntax.
It is not strictly a webservice function, but you can use it with the webservice functions that return JSON.
Syntax
Arguments
- json
- The JSON to query.
- jPath
- The JPath of the value to return.
Example
Each example uses this JSON as input, assigned to the json variable:
{ "name": "Stef Mendesidis","age":36, "music":[ { "Id" : 1, "Desc" : "Crocodiles Grin" }, { "Id" : 2, "Desc" : "Memorex" } ]}
To return the name (Stef Mendesidis):
To return the second Desc property (Memorex) of the music array:
This returns an empty string, because the music array has only two elements:
WebserviceGetBinary Function¶
Description
Sends a GET request to any URL and returns a binary value.
Use it to get binary resources, such as images, PDFs and other non-text resources, from a website or webservice.
Use it with the Base64EncodeBinary function to turn the returned value into text.
Syntax
Arguments
- url
- The URL of the resource.
- If you name a webservice behaviour, the function adds this URL to the behaviour's Base Url to make the full URL. Without a webservice behaviour, this must be the full URL.
- webservicebehaviourid
- Optional. The webservice behaviour to use for authentication, base URL, paging and throttling.
Example
To get the PNG image from the Realisable website:
To get the resource the Url field points to:
To get the resource from the labels endpoint of the PARCELFORCE webservice:
The same call, with the returned binary value converted to a Base64 string:
WebserviceGetText Function¶
Description
Sends a GET request to any URL and returns a text value, such as a CSV file, JSON or another text resource.
Syntax
Arguments
- url
- The URL of the resource.
- If you name a webservice behaviour, the function adds this URL to the behaviour's Base Url to make the full URL. Without a webservice behaviour, this must be the full URL.
- webservicebehaviourid
- Optional. The webservice behaviour to use for authentication, base URL, paging and throttling.
Example
To get a CSV file from the Realisable website:
To get the resource the Url field points to:
To get a Salesforce document, identified by the Id field, from the ContentVersion endpoint of the SALESFORCE webservice:
WebserviceLookup¶
Description
Looks up a value from a REST webservice. You define the webservice to query in Setup, Webservices, Webservice Lookup. See Webservice Lookups.
Syntax
Arguments
- lookupid
- The id of the webservice lookup.
- wherevalues
- The value or values that parameterise the query. Put several parameters in the Array function.
- mustreturnvalue
- When True, the function raises an error if the lookup returns no record.
- When False, the function returns an empty string if the lookup returns no record.
- returnpath
- Optional.
- Overrides the Return Path property of the webservice lookup. Write the return path in XPath or JPath syntax, depending on the lookup's content type.
Example
To run the SHOPIFYCUST lookup, with the Email field as the parameter to the GET request:
To run the SHOPIFYCUST lookup with the Email field as the parameter and a return path in JPath format:
To run a lookup that needs several parameters (Name and Postcode):