Single resource having different data format and data type in RAML

Author: Abhishek Bathwal

This blog will showcase how a Single resource in RAML can have different data formats and different data types.


Created a RAML with Resource as Mule and having two data format application/json and application/xml.

  1. application/json — It contains two data types JsonOne and JsonTwo.
  2. application/xml — No particular data type is defined so it can accept any type of xml input.


JsonOne: JsonTwo:

JsonOne: Contains two fields Description and type and both the fields are mandatory.

JsonTwo: Contains Only field Name and that is also mandatory.

Finally the RAML Project will look like below:

The next step will be to create the flow from the RAML Specifications:

Import the RAML to the Mule application and create the flow out of it.


Note: Just replace the logger with a Transform message to display the payload as response.


Will be using postman to test the application.

Json Format:

  1. First Datatype:

When provided the Correct field and tested then it returns the correct response:

When provided Incomplete field it returns error. Not passed the field type:

2. Second Datatype:

When provided correct field it returns correct response:

Incorrect field provided:

XML Format:

It accepts any type of field as no specific data type is defined for it.

So it verifies that a single resource can have multiple data formats and multiple data types.

Reference: MuleSoft Partner




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Beginner’s Intro with Django & Nginx

The tale of Restricted Shell bypass leading to Arbitrary Code Execution

CLASS TEACHER TURNED PROGRAMMER: What coding taught me about learning.

Basic Tutorial with TensorFlow.js: Linear Regression

What is Events Management — Events Management 101

Lessons from my Summer with One Medical; an Engineering Intern’s Perspective

Fuzzy.One-Playathon is Live in 6 days! 17-Oct-2021

Voronoi diagrams with SciPy

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


More from Medium

Connecting to the Salesforce Analytics APIs through Node.js

Plan, use and schedule Salesforce data in Conga solutions and Conga batch

Difference between Single Value Lookup , Multi Value Lookup & Joins.

Two-Factor Authentication using Face Recognition