LogoLogo
WEM ModelerWEM ReferenceTutorialsMyWEM
  • WEM Platform Documentation
  • Getting Started
    • Introducing WEM
    • Create WEM Account
    • WEM Login
    • MyWEM Portal
      • MyWEM Features
      • MyWEM Support
      • Allow Support Access
    • Partner Portal
  • WEM Modeler
    • Introducing the WEM Modeler
    • Modeler Start Page
    • Manage Projects & Workspaces
    • User Roles Scheme
    • Create a new Project
    • Modeler Application Overview
    • Project Settings
      • Project Configuration
      • Security Settings
      • Portal Settings
      • SMTP Settings
      • Mobile App Settings
    • Expression Editor
    • Flowcharts
      • User Interaction
      • End Node
      • Sub-flowchart
      • Navigation
      • Clear session
      • Decision
      • Assignment
      • List Action
      • Loop
      • Copy Data
      • Save and Discard
      • Import Data
      • Export Data
      • Invoke Webservice
      • HTTP Request
      • Execute Process
        • Different processes explained
        • Send Email
        • Change settings
        • Changing files
        • Generate File
      • Ping server
      • Authenticate
      • Comet Messages
      • OpenAI
      • Async Tasks
      • Note Node
    • Data Model
      • WEM Session Folder
    • Services and Integration
      • Webservices
      • Remote Data Sources
      • Authentication Providers
        • SAML 2.0
          • SAML App Registration in EntraID
        • OAuth 2.0
      • Comet - Real Time Messages
      • Certificates
    • Concepts and Concept Queries
      • Concepts
      • Concept Queries
      • Concept Relations
    • Navigation
      • HTTP Endpoints
      • Tasks
    • Files and Assets
      • Widget Libraries
      • Template Fragments
      • Files
      • Hyperlinks
    • Multilanguage Dictionary
    • Agentic AI
      • WEM AI Agent
      • AI Flowchart Nodes
      • AI User Interaction
    • WEM Preview
    • WEM Runtime
      • Publishing Process
      • Staging
      • Live
    • Debugging
  • Template Editor
    • Interaction Template Editor
      • Interaction Template Hotkeys
    • General and preview
    • Style
      • Heading Type
      • Paragraph Style
      • Text Styling
      • Alignment
      • Hyperlink
      • Tooltip
    • Layout
      • Adaptive columns
      • Div
      • Panel
      • Alert
      • Table
      • Image
      • Icon
      • Label
    • Interaction
      • Form
      • Validation
      • Required field
      • Button
      • Dropdown
      • Free form item
    • Miscellaneous
      • Tabbar
      • Google maps
      • Nested template
      • Script
      • Reference
      • Conditional
      • Data grid
      • Repeater
      • Rich text
      • Custom
    • WMT Tool
  • WEM Reference
    • WEM Expressions Reference
    • Functions
      • Aggregation
        • Average
        • Count
        • First
        • Last
        • Max
        • Min
        • Sum
      • Concepts
        • ConceptId
        • Description
        • FindConcepts
        • GetAncestors
        • GetChildren
        • GetDescendants
        • GetParent
        • Intersection
        • LocalName
        • Synonyms
        • ToConcept
        • Union
      • Date
        • Date
        • DateDiff
        • DateOnly
        • DatePart
        • DayOfWeek
        • FromUnixTimestamp
        • MoveDate
        • Now
        • TimeOfDay
        • Today
        • ToDuration
        • ToLocal
        • ToUnixTimestamp
        • ToUTC
        • UTCNow
        • UTCToday
      • Environment
        • ApplicationId
        • CountryCode
        • CountryName
        • Hostname
        • IpAddress
        • IsFirstRequest
        • IsHttps
        • IsPreview
        • IsStaging
        • IsLive
        • NodeTrail
        • PortalId
        • PortalName
        • ProjectId
        • ProjectName
        • ProjectVersion
        • Setting
        • UrlPath
      • Files
        • FileName
        • FileSize
        • FileUrl
        • MimeType
      • Lists
        • Distinct
        • IsNewRow
        • IsOnRow
        • List
        • NameOf
        • RowId
      • Math
        • Abs
        • Ceiling
        • Cos
        • Distance
        • Exp
        • Floor
        • Log
        • Log10
        • Pi
        • Pow
        • Random
        • Round
        • Sin
        • Sqrt
        • ToNumber
      • Security
        • AesDecrypt
        • AesEncrypt
        • AesIv
        • AesKey
        • CreateJsonWebTokenH256
        • HmacSha256
        • Md5
        • Password
        • PasswordStrength
        • Pbkdf2
        • Sha1
        • Sha256
        • Totp
      • Text
        • AsText
        • Base32ToText
        • Base64ToText
        • CompareFuzzy
        • Concat
        • Contains
        • FormatDate
        • FormatDuration
        • FormatNumber
        • Guid
        • HexToText
        • HtmlAttributeEncode
        • HtmlEncode
        • IndexOf
        • JavascriptEncode
        • JsonEncode
        • Length
        • Padl
        • Padr
        • RegExIsMatch
        • RegExMatches
        • RegExReplace
        • Replace
        • Split
        • StringPart
        • SubString
        • ToBase32
        • ToBase64
        • ToBase64Url
        • ToHex
        • ToLower
        • ToRichText
        • ToString
        • ToTitleCase
        • ToUpper
        • Trim
        • UrlDecode
        • UrlEncode
        • XmlAttributeEncode
        • XmlEncode
        • XPath
        • XPathList
        • XPathNumber
      • Validation
        • HasValue
        • IsEmpty
        • IsKnown
        • IsUnknown
        • IsValidBankaccount
        • IsValidBSN
        • IsValidBTW
        • IsValidEmailAddress
        • IsValidIBAN
        • IsValidPhonenumber
        • IsValidURL
      • Localization
        • AvailableLanguages
        • CurrentLanguage
        • CurrentTimezone
        • LanguageStrategy
        • Languages in WEM
    • Keywords
      • Contains
      • Concepts
        • Ancestor of
        • Child of
        • Concept
        • Descendant of
        • Overlaps
        • Range of
        • Parent of
        • Contains
      • Environment
        • ApplicationRoot
        • Platform
      • Lists
        • In
        • Of
        • Where
        • Contains
        • All
      • Logic
        • And
        • Not
        • Or
        • Choose
        • If Then Else
      • Mobile
        • BatteryLife
        • BuildVersion
        • ConnectivityTypes
        • DeviceId
        • DeviceName
        • IsDevelopmentBuild
        • IsDistributionBuild
      • Text
        • Contains
        • Ends with
        • NewLine
        • Starts with
    • Operators
      • Addition +
      • Division /
      • Equality =
      • Equality-strong ==
      • Greater-than >
      • Greater-than-or-equal >=
      • If-unknown ?
      • Inversion -
      • Less-than <
      • Less-than-or-equal <=
      • Logical-and &, and
      • Logical-not !, not
      • Logical-or |, or
      • Modulo %
      • Multiplication *
      • Power ^
      • Subtraction -
      • Unequality <>
    • Data Types
      • Text
      • Number
      • Yes / No (Boolean)
      • Date Time
      • Duration
      • File
      • Rich Text
      • Concept
      • Conceptset
      • Reference
    • SQL Compatibility
      • Functions
      • Keywords
      • Operators
    • Content Security Policy
    • WEMScript for Custom HTML
    • WEM Widgets
      • WEM Widget Structure
      • WEMScript for Widgets
      • Widget Editor
      • Content Placeholder
    • WMT
      • File Structure
      • Basic Functional Template
      • Styling
      • Font Icons
      • Reference
        • Breadcrumb
        • Button Bar Buttons
        • Common Scripts
        • Common Styles
        • Conditional
        • Content
        • CSP
        • CSP Nonce
        • Expression
        • Hidden Fields
        • Language Select
        • Navigation
        • Node ID
        • Node Name
        • Placeholder
        • Placeholder Conditional
        • Startup Scripts
        • Template Fragment
        • Uses
    • Regression Test Framework
      • WEM Test Script
  • Tutorials
    • Tutorials
      • Making a Change Log
      • Placeholders for end-users
    • First Application
      • Expand First Application
    • Video Tutorials
      • By Partners
      • Security
    • Building Widgets
      • Basics
        • 1. Introduction
        • 2. Hello, World!
        • 3. General
        • 4. Properties
        • 5. Events
        • 6. Styling
        • 7. View State
        • 8. Resources
        • 9. Placeholders
        • 10. Template Editor Script
        • 11. Global Scope
        • 12. Risks and Responsibilities
        • 13. Conclusion
      • In-depth
        • 1. Introduction
        • 2. Platform Availability
        • 3. Development Workflow
        • 4. Properties
        • 5. View state
          • 1. Runtime.viewState
          • 2. sessionStorage
          • 3. Summary
        • 6. Styling
        • 7. Events
          • 1. Navigation
          • 2. Row position
      • WEMscript
        • 1. Introduction
        • 2. Variables
        • 3. Properties
        • 4. OutputId()
        • 5. Register Input - Required
        • 6. Encoding
        • 7. Script Block - Introduction
        • 8. Types
          • 1. Boolean
          • 2. Concept
          • 3. ConceptSet
          • 4. Datetime
          • 5. Duration
          • 6. File
          • 7. Number
          • 8. Richtext
          • 9. Text
        • 9. Script Block - Global Scope
        • 10. Script Block - ES Modules
        • 11. CSS - attachShadow
      • Examples
  • Tips and Tricks
    • Tips and Tricks
      • Keyboard Shortcuts
      • Video's in WEM
      • Extracting text from File
    • Custom Hostnames
    • FAQ
    • Expressions
      • Order of Operators
    • Processes
      • Email Process
      • Tips for creating PDF's
      • ZIP Archive Process Node
    • Concepts
      • Concepts and Runtime
    • Working with data
      • The Power of the Calculated Field
      • Consuming your OData source with Excel 2016
      • Expose your data via OData
      • Using OData to transfer data between runtimes
      • WEM Storage Options
    • Integration
      • Integrating external systems
      • Json
      • Single Sign-on
      • Office365 Integration
    • Performance
      • Performance Tips
      • Performance Profiler
      • Template Performance Profiler
      • The Split Loop
    • Security
      • 2FA with TOTP
      • Blacklist or whitelist IP addresses
    • Widgets
      • Advanced Charts
        • Boxplot Chart
        • Brush Chart
        • Bubble Chart
        • Candlestick Chart
        • Card with Chart
        • Effect Scatter Chart
        • Heat Map
        • Line, Area and Bar Chart
        • Map-Bar Morph
        • Mix Time Line Chart
        • Nested Pie Chart
        • Polar Area Chart
        • Polar Bar Chart
        • Profit Chart
        • Radial Bar Chart
        • Radial Bar Gauge
        • Range Bar Chart
        • Rosetype Pie Chart
        • Sankey Energy Chart
        • Scatter Chart
        • Scatter-Aggregate-Bar Chart
        • Stacked Columns Chart
        • Stepline Chart
        • Treemap
      • Advanced Input
        • Color Picker
        • Conceptset Image Selector
        • Google maps locator
        • Multi select input button
        • MultiFile Upload
        • On/Off switch
        • Process Arrow Steps
        • Rate
        • Rating view
        • Single select input button
        • Slider
        • Tree
      • Template Actions
        • Follow exit
      • Global widgets
        • Agenda
        • Audio Player
        • Calendar
        • Draw Signature
        • Grid Widget
        • Image capture
        • Kanban Board
        • Path
        • Progress Bar
        • reCAPTCHA
        • Timeline
      • Document widgets
        • Json Viewer
        • PDF Viewer
    • Various
    • Go to MyWEM
Powered by GitBook
On this page
  • Consuming a JSON webservice
  • Importing aJSON message into a data list

Was this helpful?

Export as PDF
  1. Tips and Tricks
  2. Integration

Json

Consuming a JSON webservice

PreviousIntegrating external systemsNextSingle Sign-on

Last updated 1 year ago

Was this helpful?

Consuming a JSON webservice

This article explains how to consume a JSON webservice from within your WEM project. At the end of this article we will have built a simple application that uses the to search for a movie and show the details. You can already see the final application working at .

This part of this article explores a new feature in WEM that allows you to perform any HTTP web request. The second part will focus on JSON messages and how to handle them in WEM.

Introducing a new flowchart node

HTTP (Hypertext Transfer Protocol) is the protocol that is used to communicate with web servers. Your browser sends an HTTP request to a web server any time you request a new web page, while webservers use HTTP to communicate with each other through webservices.

We recently added a new node type to the flowchart editor that can perform any HTTP web request, and conveniently called it the “web request node“. When you drag this node in your flowchart, you can specify all the aspects that make up an HTTP request message:

  • The url (this includes the scheme, which is either http or https).

  • The request method (GET and POST are the most common methods, but WEM supports all common methods).

  • Request headers – The header fields Accept, Connection and Content-Type are predefined. You can specify any number of additional headers.

  • Query fields – You can manually put the queryfields in the url yourself, but I recommend to specify them separately. This way WEM will take care of proper url encoding.

  • The request body, if applicable. This can either be plain text (for instance, json or xml) or a document such as an image or a pdf file.

When it comes to security, WEM supports basic authentication and client certificates out of the box. Other authentication schemes are often possible through custom HTTP headers.

The web request node also lets you specify how to handle the web response that you get back from the server. You can map each response header to a data field, and the response body can be stored in either a text field or a file field. The node has an error exit that is followed when the server is not available or when the server responds with a 50x Server Error. You can also add exits to handle specific server responses, such as 404 Not Found or 401 Unauthorized.

Using the Open Movie Database API

Searching the Open Movie Database is very easy. It consists of a simple GET request to https://www.omdbapi.com/with some query fields:

  • s – The movie title to search for.

  • y – The year of release (_optional_).

  • r – The message format of the response (json or xml).

There are more optional query fields, but these are the three that are used in the demo application. You can even try the API in your browser, and inspect the JSON response:

For our example I created a simple flowchart:

The first node contains a simple form where the user can enter (a part of) the title and year of the movie. I created two data fields named [Search.Title] and [Search.Year] for this form.

The second node is the new web request node. It performs a GET request to the url "http://www.omdbapi.com/". No authentication is needed. The response body is stored in an other data field [Response.Json]. This is a plain text field. The following three query fields are added for this request:

Note that the query field r contains the literal text "json". This instructs this particular webservice to send the response in json format.

The last node in the flowchart is an overlay that shows the JSON message. When I searched for “The Godfather”, I received the following json response:

Importing aJSON message into a data list

The first part of this article described how to use the web request node to send an HTTP web request to a json webservice. The response was a JSON message. This part shows how to import the JSON message into WEM data fields.

WEM has data import and export nodes, a convenient way to import or export excel or CSV files. We recently added the option to import JSON data.

Importing JSON data is different from importing tabular data.

What is a JSON message?

JSON stands for JavasScript Object Notation. It describes data in a text-based and human-readable format. JSON is often used in conjunction with REST APIs and web-based services. It is more powerfull than for example CSV, because it isn’t restricted to tabular data.

The following example is a JSON message that contains information about a person “John Smith”:

The basic construct for JSON messages is the so called object. An object is a list of “key/value” pairs surrounded by curly brackets ({}). The message itself is an object. In the example above, the line "firstName": "John" is a key/value pair. The key in this case is firstName, and the value is "John".

Key is always surrounded by quotes. The value can be any of the following type:

  • A string (e.g. text). For example, the value "John" is a string. Strings are always surrounded by quotes.

  • A number. In the example above, the age and height are numbers. Numbers are not surrounded by quotes.

  • A boolean (e.g. true or false). In the example, a boolean is used for the key "isMember".

  • The value null can be used when the actual value is unknown or missing.

  • A value can again be an object. This allows for nesting of objects. In the example above, the address is an object that contains the keys "street", "postcode" and "place".

  • A value can also be a list (called an _array_) of values. This list is surrounded by square brackets ([]). In the example above "phoneNumbers" is a list of objects.

An important aspect is that JSON messages can be deeply nested. It isn’t unusual to see a message that contains a list of objects, where each object again contains a list of objects, etc…

Importing a JSON message

We will now import this JSON response using the data import node. A new drop down is added to the data import node, that allows you to choose the file format. It this case we choose JSON. Next, we have to specify the data source. This sould be the data field that was used by the web request node to store the response body.

If we click Edit Mappings, an overlay appears that allows you to describe the structure of the JSON message, and map the fields and arrays to data fields in WEM. For CSV, you could specify a flat list of columns. JSON has a nested structure however, so you define this structure by building a tree. This tree consists of objects, arrays, text fields, number fields or “true/false” fields, which corresponds to the different JSON value types described above. The tree that describes the response of the OMDB query looks as follows:

Now, instead of building this tree structure manually, I used the feature “Create mapping from example”. This allows you to copy & paste the JSON result and let WEM infer the JSON structure based on this result. This saves a lot of time, and you can always refine the structure if WEM wasn’t able to infer everything from one example.

The next step is to map the the JSON fields to data fields in WEM. For this, I created the following data model in WEM:

For the next step, we have to map the JSON fields to the corresponding WEM data fields. You do this simply by clicking on the field, and choosing the corresponding data field by clicking on the “Map to” button. After all the relevant fields are mapped, the tree should look like this:

Now that we have imported the data, we can simply build a page that shows the results. In this example, we used a repeater and a panel to list all the movies:

In part one of this blog we used the . This API contains a method to search for movies, given a title and optionally a year. The following query searches for the Jurassic Park movies: http://www.omdbapi.com/?s=Jurassic+Park&r=json

Open Movie Database API
https://omdb.live.wem.io
http://www.omdbapi.com?s=Matrix&y=1999&r=json
Open Movie Database API