DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • User-Friendly API Publishing and Testing With Retrofit
  • GraphQL vs REST API: Which Is Better for Your Project in 2025?
  • Building a REST Service That Collects HTML Form Data Using Netbeans, Jersey, Apache Tomcat, and Java
  • Spring Boot - How To Use Native SQL Queries | Restful Web Services

Trending

  • How to Build a Local LLM Agent to Automate Work List Generation from Monthly Reports (With Jira Integration)
  • Why Your AI Agent's Logs Aren't Earning Trust
  • Give Your AI Assistant Long-Term Memory With perag
  • Native SQL in Java Without JDBC Boilerplate — Meet Ujorm3
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. How to Update Object Store Values Using Object Store V2 REST APIs: Mule4

How to Update Object Store Values Using Object Store V2 REST APIs: Mule4

In this tutorial, learn how to use Object Store V2 REST APIs to dynamically update the values present in Object Store without making any changes to our code.

By 
Gundeep Singh user avatar
Gundeep Singh
·
Dec. 31, 21 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
12.1K Views

Join the DZone community and get the full member experience.

Join For Free

Object Store in MuleSoft is used to store key-value pairs that we might need to preserve for future use. In this tutorial, we will learn how we can use Object Store V2 REST APIs to dynamically update the values present in our object store without making any changes to our code.

For a detailed explanation on Object Store and rest APIs please refer to official MuleSoft documentation.

Prerequisites: 

  1. An App that uses Object Store v2 and is deployed to CloudHub
  2. Access Token for the Anypoint Platform User

Access Object Store v2 API:

In order to access the REST APIs, we would need the following details:

  1. Organization ID
  2. Environment ID
  3. Base URL
  4. Access Token

Steps for Organization ID:

  1. Login to the Anypoint Platform.
  2. Click on Access Management:Access Management
  3. Inside Access Management, choose the organization tab and click on your desired business group.
  4. Add Business GroupCopy and save the Organization Id.

Organization ID

Steps for the Environment ID:

  1. Login to the Anypoint Platform.
  2. Click on API Manager.
  3. API ManagerMake sure you are in your desired Environment and then click on the "i" button to get Environment Information.
  4. Environment InformationCopy and save the Environment Id.

Environment ID

NOTE: Based on the region your app is deployed in you can get the Base URL from below:

Control Plane BASE_URL Region

U.S.

object-store-us-east-1.anypoint.mulesoft.com

US East (N. Virginia)

object-store-us-east-2.anypoint.mulesoft.com

US East (Ohio)

object-store-us-west-1.anypoint.mulesoft.com

US West (N. California)

object-store-us-west-2.anypoint.mulesoft.com

US West (Oregon)

object-store-ap-southeast-1.anypoint.mulesoft.com

Asia Pacific (Singapore)

object-store-ap-southeast-2.anypoint.mulesoft.com

Asia Pacific (Sydney)

object-store-ap-northeast-1.anypoint.mulesoft.com

Asia Pacific (Tokyo)

object-store-ca-central-1.anypoint.mulesoft.com

Canada (Central)

object-store-eu-central-1.anypoint.mulesoft.com

Europe (Frankfurt)

object-store-eu-west-1.anypoint.mulesoft.com

Europe (London)

object-store-eu-west-2.anypoint.mulesoft.com

Europe (Ireland)

object-store-sa-east-1.anypoint.mulesoft.com

South America (São Paulo)

Steps for the Access Token:

  1. Make a POST call to the below URL, by passing the username and password for your Anypoint platform user.

https://anypoint.mulesoft.com/accounts/login  

NOTE: The user must have Admin Access in order to retrieve the token.

Access Token2.  Copy and save the access token.

Retrieve the List of Object Stores

In order to retrieve the list of object stores in a particular Environment, make a GET call to the below URL using Postman:

https://BASE_URL/api/v1/organizations/ORG_ID/environments/ENV_ID/stores 

Change the values of BASE_URL, ORG_ID, and ENV_ID to the one retrieved earlier.

NOTE: Do pass the Access Token in headers as Type Bearer.

Store ID

On a similar line, you can use the below URL to get the list of partitions:

https://BASE_URL/api/v1/organizations/ORG_ID/environments/ENV_ID/stores/STORE_ID/partitions

Update Value for a Particular Key In Object Store

In order to update the value for a particular key, make a PUT call to the below URL and pass the body in the below format:

https://BASE_URL/api/v1/organizations/ORG_ID/environments/ENV_ID/stores/STORE_ID/partitions/PARTITION_ID/keys/KEY_ID

Change the values of BASE_URL, ORG_ID, ENV_ID, STORE_ID, and PARTITION_ID to the one retrieved earlier. Also, pass the KEY_ID (i.e. name of the key that you want to update).

BODY:

 
{

    "keyId" : "currentDate",

    "valueType" : "STRING",

    "stringValue" : "2021-12-30"

}

Body

This is how we can update the value of a key in Object Store v2 using REST APIs.

REST Web Protocols Object (computer science)

Opinions expressed by DZone contributors are their own.

Related

  • User-Friendly API Publishing and Testing With Retrofit
  • GraphQL vs REST API: Which Is Better for Your Project in 2025?
  • Building a REST Service That Collects HTML Form Data Using Netbeans, Jersey, Apache Tomcat, and Java
  • Spring Boot - How To Use Native SQL Queries | Restful Web Services

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook