• Latest
Mulesoft OData – DZone Integration

Mulesoft OData – DZone Integration

January 5, 2022
Final Fantasy XIV Has Resumed Their Housing Lottery System

Final Fantasy XIV Has Resumed Their Housing Lottery System

May 28, 2022
9to5Mac Happy Hour 364: iPhone 14 pill holes, Beddit discontinued, Apple-MLB rumors

9to5Mac Happy Hour 383: Apple AR headset tidbits, new Pride Band, WWDC approaches

May 28, 2022
USB-C cable alert feaure should come to Mac and iPad

USB-C cable alert feaure should come to Mac and iPad

May 28, 2022
WB Changes Batgirl’s Gotham Knights Biography Following Criticism

WB Changes Batgirl’s Gotham Knights Biography Following Criticism

May 28, 2022
Destiny 2: Where Is Xur Today? Location and Exotic Items for March 4

Destiny 2: Where Is Xur Today? Location and Exotic Items for May 27-31

May 28, 2022
Pac-Man’s Family All Have VERY Different Names In Pac-Man Museum+

Pac-Man’s Family All Have VERY Different Names In Pac-Man Museum+

May 28, 2022
The Quarry’s Online Multiplayer Mode Has Been Delayed

The Quarry’s Online Multiplayer Mode Has Been Delayed

May 28, 2022
Evil Dead: The Game Review – Not Very Groovy

Evil Dead: The Game Review – Not Very Groovy

May 27, 2022
Love the trinity lenses? Try these great alternatives instead!

Love the trinity lenses? Try these great alternatives instead!

May 27, 2022
Apple supplier lockdown: Quanta workers rebel

Apple supplier lockdown: Quanta workers rebel

May 27, 2022
Pokkén Tournament Won’t Be Supported Competitively After 2022 Championships

Pokkén Tournament Won’t Be Supported Competitively After 2022 Championships

May 27, 2022
Xmake and C/C++ Package Management

Xmake and C/C++ Package Management

May 27, 2022
Advertise with us
Saturday, May 28, 2022
Bookmarks
  • Login
  • Register
GetUpdated
  • Home
  • Game Updates
    • Mobile Gaming
    • Playstation News
    • Xbox News
    • Switch News
    • MMORPG
    • Game News
    • IGN
    • Retro Gaming
  • Tech News
    • Apple Updates
    • Jailbreak News
    • Mobile News
  • Software Development
  • Photography
  • Contact
    • Advertise With Us
    • About
No Result
View All Result
GetUpdated
No Result
View All Result
GetUpdated
No Result
View All Result
ADVERTISEMENT

Mulesoft OData – DZone Integration

January 5, 2022
in Software Development
Reading Time:7 mins read
0 0
0
Share on FacebookShare on WhatsAppShare on Twitter


This article will help you build an OData Rest API. Before reading, below are a few prerequisites to be taken care of:

  • Anypoint Studio 7.1.4 or later. (Download Link: Anypoint Studio).
  • Mule Runtime Engine 4.1.1 or later.
  • Install OData Plugin in-studio below are the steps:
    • Open Anypoint Studio –> Help –> Install New Software.Installation screenshot.
    • Click on Add option and Add below URL in the location section and then select the OData v2 Plugin to install it in Anypoint Studio.

Let’s start now with the development; we will be working on a simple use case for creating an OData Rest API for Salesforce Opportunity Object. 

  1. The first step is to create the OData Model i.e. odata.raml file. This Model structure will have the dataType definition along with the properties for each field. Here is the link for the list of dataType you can define.
    1. Link
      #%RAML 1.0 Library
      
      uses:
        odata: libraries/odataLibrary.raml
      
      types:
        Opportunity:
          (odata.remote): Opportunity 
          properties:
            CurrencyIsoCode:
              type: number
              (odata.key): true
              (odata.nullable): false
              format: int32
              required: false
            Description:
              type: string
              (odata.nullable): false
              (odata.key): true
              maxLength: 40
            Fiscal:
              type: string
              (odata.nullable): true
              (odata.key): false
            FiscalQuarter:
              type: number
              (odata.nullable): true
              (odata.key): false
              format: int16
            FiscalYear:
              type: number
              (odata.nullable): true
              (odata.key): false
              format: int16
            ForecastCategory:
              type: string
              (odata.nullable): true
              (odata.key): false
            ForecastCategoryName:
              type: string
              (odata.nullable): true
              (odata.key): false
            HasOpenActivity:
              type: boolean
              (odata.nullable): true
              (odata.key): false
            StageName:
              type: string
              (odata.nullable): true
              (odata.key): false
            CloseDate:
              type: date-only
              (odata.nullable): true
              (odata.key): false
            Name:
              type: string
              (odata.nullable): true
              (odata.key): false

  2. Once the odata.raml file is ready, we can now create a new project in Anypoint Studio and add this file at the below location.
    API screenshot.
  3. Now, it will auto-generate the main raml file(api.raml) and the libraries file i.e. odataLibrary.raml (Library file path defined in above RAML code) by right-clicking on odata.raml file and selecting Mule –> Generate OData API from RAML File.Mule generate screenshot.
  4. Below is the content you can see in the odataLibrary. raml file. It has two things. First, is the Annotation type used by the odata.raml file, and second, is the Query parameters that can be used for Quering the Service.Content screenshot.
    traits:
      orderby:
        queryParameters:
          orderby:
            description: Expression for determining what values are used to order the collection of Entries
            type: string
            required: false
      top:
        queryParameters:
          top:
            description: Identifies a subset formed by selecting only the first N items of the set, where N is a positive integer specified by this query option
            type: number
            required: false
      skip:
        queryParameters:
          skip:
            description: Identifies a subset defined by seeking N Entries into the Collection and selecting only the remaining Entries (starting with Entry N+1)
            type: number
            required: false
      filter:
        queryParameters:
          filter:
            description: Identifies a subset determined by selecting only the Entries that satisfy the predicate expression specified by the query option
            type: string
            required: false
      expand:
        queryParameters:
          expand:
            description: A URI with a expand System Query Option indicates that Entries associated with the Entry or Collection of Entries identified by the Resource Path section of the URI must be represented inline
            type: string
            required: false
      format:
        queryParameters:
          format:
            description: If the format query option is present in a request URI it takes precedence over the value(s) specified in the Accept request header. Valid values for the $format query string option are listed in the following table.
            type: string
            required: false
      select:
        queryParameters:
          select:
            description: Specifies that a response from an OData service should return a subset of the Properties which would have been returned had the URI not included a select query option.
            type: string
            required: false
      inlinecount:
        queryParameters:
          inlinecount:
            description: Specifies that the response to the request includes a count of the number of Entries in the Collection
            type: string
            required: false

  5. In the api.raml file, the specification is created based on the data model defined in the odata.raml file. Also, in src/main/mule, the api.xml file is created using scaffolding. This Scaffolding will create separate flows for each method (GET, POST, PUT, DELETE) for the opportunity resource as per our use case. As per our odata model, below will be the flows generated in the api.xml file.Generated flows screenshot.
  6. Now, we can do our implementation to fetch opportunity data from salesforce using get:Opportunities flow. Below is a sample implementation for the same. For the odata response, you need to follow the defined output structure as below:Output screenshot.Code screenshot.
  7. Once done with the implementation, run the code locally and use the below URL to get the required output as needed.
    1. To call Rest API: Rest API.
    2. To get the description of OData Service:Description code screenshot.
  8. To get the odata Service metadata:  Service metadata screenshot.
  9. To use Query for odata Service:  Query service screenshot.



Source link

ShareSendTweet
Previous Post

NEW JBL PULSE 5??? (Spoiler: Not what i tought coming)

Next Post

Yeah…What They Said: Galaxy S21 FE Unboxing & First Look(s)

Related Posts

Xmake and C/C++ Package Management

May 27, 2022
0
0
Xmake and C/C++ Package Management
Software Development

Xmake is a lightweight cross-platform build tool based on Lua. A previous article provides a detailed introduction to Xmake and...

Read more

What Is Smoke Testing? – A Brief Guide

May 27, 2022
0
0
What Is Smoke Testing? – A Brief Guide
Software Development

Smoke testing is a method of determining whether a newly released build is stable. It assists a QA or testing...

Read more
Next Post
Yeah…What They Said: Galaxy S21 FE Unboxing & First Look(s)

Yeah...What They Said: Galaxy S21 FE Unboxing & First Look(s)

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

© 2021 GetUpdated – MW.

  • About
  • Advertise
  • Privacy & Policy
  • Terms & Conditions
  • Contact

No Result
View All Result
  • Home
  • Game Updates
    • Mobile Gaming
    • Playstation News
    • Xbox News
    • Switch News
    • MMORPG
    • Game News
    • IGN
    • Retro Gaming
  • Tech News
    • Apple Updates
    • Jailbreak News
    • Mobile News
  • Software Development
  • Photography
  • Contact
    • Advertise With Us
    • About

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?