How to Store this Value in Entitys Attribute

0
    Could you help me understand how to extract the httpRequest.Content Value from a POST request in Mendix? My goal is to store this value in an entity. Could you provide me with the correct steps or syntax to achieve this?
asked
1 answers
0

Hi Rahul,

 

When you create a published REST service in Mendix, the POST request body (raw JSON/text/XML) is available through the $HttpRequest/Content variable inside the microflow that handles the request.

Below is the correct way to read and store that content.

---Step-by-Step Solution

1. Open your Published REST POST operation

Go toApp Explorer → Published REST Services → Your Service → POST Action

The POST action will point to a microflow (example: POST_Handler)

---

Inside the microflow, use the built-in HttpRequest parameter

Mendix automatically passes a parameter:

HttpRequest (System.HttpRequest)

This contains:

Headers

Query parameters

Content → the raw body of the POST request

---Create a string variable to store request content

Add → Create Variable

Name: ReceivedContentType: StringValue: $HttpRequest/Content

This variable now contains the full body sent by the client.

---

Parse the content if needed

If POST body is JSON:

Use Import MappingORUse JSON structure → Import Mapping to convert it into an entity.

---

Save into your entity

Example:

Create object → YourEntitySet attribute:

YourEntity.RawBody = $ReceivedContent

Commit the object.

answered