Use json objects. Do something like that. Don't write json by hand, you could easily do a mistake.
public JSON() throws JSONException
{
JSONArray locArr=new JSONArray();
locArr.put(createLatLng(40.900799, 8.606102));
locArr.put(createLatLng(42.900799, 9.606102));
JSONObject main=new JSONObject();
main.put("locations", locArr);
Log.d("JSON",main.toString());
}
public JSONObject createLatLng(double lat, double lng) throws JSONException
{
JSONObject latLng=new JSONObject();
latLng.put("lat",lat);
latLng.put("lon",lng);
JSONObject latLngWrap=new JSONObject();
latLngWrap.put("latLng",latLng);
return latLngWrap;
}
Answer from maciekczwa on Stack Overflow Top answer 1 of 3
3
Use json objects. Do something like that. Don't write json by hand, you could easily do a mistake.
public JSON() throws JSONException
{
JSONArray locArr=new JSONArray();
locArr.put(createLatLng(40.900799, 8.606102));
locArr.put(createLatLng(42.900799, 9.606102));
JSONObject main=new JSONObject();
main.put("locations", locArr);
Log.d("JSON",main.toString());
}
public JSONObject createLatLng(double lat, double lng) throws JSONException
{
JSONObject latLng=new JSONObject();
latLng.put("lat",lat);
latLng.put("lon",lng);
JSONObject latLngWrap=new JSONObject();
latLngWrap.put("latLng",latLng);
return latLngWrap;
}
2 of 3
1
JSON notation requires the "" around field names. Values should only be wrapped, if they are string.
{
"locations":
[
{
"latLng":
{
"lat": 40.900799,
"lng": 8.606102
}
},
{
"latLng":
{
"lat": 42.900799,
"lng": 9.606102
}
}
]
}
You can always verify, if you JSON is correct using http://jsonlint.com/
Postman
postman.com › postman › postman-team-collections › request › ii8syuh › using-json-request-body
Using JSON request body | Working with GraphQL
We cannot provide a description for this page right now
Adding Json Body to a HTTP request
Hi Need to add the below request to a HTTP Request. However I cant workout how to escape the double quotes, I’ve tried using “”" but it doesn’t seem to be accepted by the editor Code I want { “type”: “select”, “whe… More on forum.uipath.com
How to pass values (parameters) into a JSON request body for a POST API | OutSystems
How to pass values (parameters) into a JSON request body for a POST API More on outsystems.com
Creating a request with raw json body
I am trying to create a request inside a new/update collection API call, having the equivalent of the raw - json body inside the client. Right now, it seems like I need to send something like (I am using ruby, but it shouldn’t make a big different): body: { mode: 'raw', json: { field1: 'value', ... More on community.postman.com
apex - Add JSON string in JSON body - Salesforce Stack Exchange
Is there a way I can pass JSON string in the JSON body. More on salesforce.stackexchange.com
Videos
01:21
How to Format and View JSON in Postman Tutorial - YouTube
10:09
Learn JSON files in 10 minutes! 📄 - YouTube
12:00
Learn JSON in 10 Minutes - YouTube
04:42
How to pass JSON Request Body in REST API Using HTTP POST method ...
03:18
JSON POST request with Postman - YouTube
Set the JSON body from an external JSON file in Postman
JSON
json.org › example.html
JSON Example
This page shows examples of messages formatted using JSON (JavaScript Object Notation).
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Request › json
Request: json() method - Web APIs | MDN
November 7, 2025 - The request body cannot be parsed as JSON. ... const obj = { hello: "world" }; const request = new Request("/myEndpoint", { method: "POST", body: JSON.stringify(obj), }); request.json().then((data) => { // do something with the data sent in the request });
Informatica
docs.informatica.com › reference material › rest api reference › informatica intelligent cloud services rest api › header and body configuration › json format example
JSON format example
You can then use the sessionId and the baseapiUrl to construct a request to obtain your organization's license information, for example: GET https://https://usw3.dm-us.informaticacloud.com/saas/public/core/v3/license/org/52ZSTB0IDK6dXxaEQLUaQu Content-Type: application/json Accept: application/json INFA-SESSION-ID: 9KA11tLGqxVcGeul8SQBK3 · Header and body configuration ·
Baeldung
baeldung.com › home › web › sending json http request body in terminal
Sending JSON HTTP Request Body in Terminal | Baeldung on Linux
March 18, 2024 - In this tutorial, we’ll be learning how to send JSON objects as the request body correctly with the help of the Content-Type HTTP header. In Linux, curl and wget are the common terminal-based HTTP clients. Given its popularity in the Linux ecosystem, we’ll be using them in this article for demonstration purposes. To obtain curl and wget, we can install them using the package manager. For example...
Atlassian
developer.atlassian.com › server › crowd › json-requests-and-responses
JSON requests and responses
These samples show the JSON representations that the Crowd REST Resources expect to receive. ... { "name" : "my_username", "first-name" : "My", "last-name" : "Username", "display-name" : "My Username", "email" : "user@example.test", "password" : { "value" : "my_password" }, "active" : true }
Practical Go Lessons
practical-go-lessons.com › post › go-how-to-send-post-http-requests-with-a-json-body-cbhvuqa220ds70kp2lkg
Go: How to send POST HTTP requests with a JSON body| Practical Go Lessons
Suppose you want to run this request: POST https://example.com/teacher. With the following JSON body: { "id": "42", "firstname": "John", "lastname": "Doe" } The first step is to build the body.
ReqBin
reqbin.com › req › 4rwevrqh › post-json-example
How do I post JSON to the server?
January 16, 2023 - The Content-Type request header specifies the media type for the resource in the body. Additionally, you can pass an "Accept: application/json" header, which tells the server that the client is expecting JSON data. In this POST JSON example, we send JSON data to the ReqBin echo URL with the ...
Medium
medium.com › @guptadiksha88 › best-practices-for-handling-json-request-bodies-in-post-api-calls-1b19fc6a8da7
“Best Practices for Handling JSON Request Bodies in POST API Calls” | by Diksha Gupta | Medium
May 24, 2023 - Common content types include “application/x-www-form-urlencoded” for form data and “application/json” for JSON data. The server, upon receiving the POST request, processes the data. Once the server has processed the request, it sends an HTTP response back to the client, indicating the status of the operation. Now let’s discuss one POST request as shown below ... Here, through this request, we want to create a new placeholder resource on the server by providing all the required values in the request body.On the server side, the new resource will be created with all the provided information and a response will be sent back to the client.
Top answer 1 of 16
4
Hi @barryrodick
Better way is to write the json body to be written in text file and then use read text file activitiy and store the data in string variable and placing the string varaible in json body part of http request activitiy
Hope the idea helps you
Regards
Nived N :robot:
Happy Automatio…
2 of 16
1
Thanks, much easier!
OutSystems
outsystems.com › forums › discussion › 74386 › how-to-pass-values-parameters-into-a-json-request-body-for-a-post-api
How to pass values (parameters) into a JSON request body for a POST API | OutSystems
How to pass values (parameters) into a JSON request body for a POST API
FastAPI
fastapi.tiangolo.com › tutorial › body
Request Body - FastAPI
...as description and tax are optional (with a default value of None), this JSON "object" would also be valid: ... from fastapi import FastAPI from pydantic import BaseModel class Item(BaseModel): name: str description: str | None = None price: float tax: float | None = None app = FastAPI() @app.post("/items/") async def create_item(item: Item): return item · ...and declare its type as the model you created, Item. With just that Python type declaration, FastAPI will: Read the body of the request as JSON.
Postman
community.postman.com › help hub
Creating a request with raw json body - Help Hub - Postman Community
July 1, 2021 - I am trying to create a request inside a new/update collection API call, having the equivalent of the raw - json body inside the client. Right now, it seems like I need to send something like (I am using ruby, but it shouldn’t make a big different): body: { mode: 'raw', json: { field1: 'value', field2: 'value2' } } I want to avoid using 'formdata', because I already have the hash and parsing it into formdata format would add extra complexity (especially because I have to handle ...
IBM
ibm.com › docs › en › netcoolomnibus › 8.1.0
Example JSON payloads
Examples of JSON message payloads.
Top answer 1 of 3
5
I suggest:
String encoded = JSON.serialize('{"id": "0684D0000004VgeTTE", "success": true, "errors": []}');
that generates this string that is a valid JSON value:
"{\"id\": \"0684D0000004VgeTTE\", \"success\": true, \"errors\": []}"
that can be set as the "machinename" value. It keeps the logic in the JSON world.
2 of 3
2
There may be a better way to do this, but URLEncoding it seems to work.
Try this:
String jsonStr = '{"id":"0684D0000004VgeTTE","success":true,"errors":[]}';
String encoded = EncodingUtil.urlEncode(jsonStr, 'UTF-8');
String jsonStr2 = '{"description":"Some Text","machinename":"' + encoded + '","ipaddress":"192.128.0.0","version":"v3"}';
Map<String,Object> obj = (Map<String, Object>)JSON.deserializeUntyped(jsonStr2);
System.debug(EncodingUtil.urlDecode((String)obj.get('machinename'), 'UTF-8'));
Of course it all depends what you are going to do with it on the other end, but this may be useful for you.
EasyMorph Community
community.easymorph.com › t › post-request-with-nested-json-body-how-can-i-generate-it › 2933
POST Request with nested JSON Body - how can I generate it? - EasyMorph Community - Data preparation professionals and enthusiasts
July 30, 2021 - Hello, I'm trying to send data through a JSON Body, however I think that the API receiving the data is expecting a nested JSON, with the text "inputs" in the first level, and the inputs themselves in the second level: More details: https://developer.salesforce.com/docs/atlas.en-us.api_action.meta/api_action/actions_obj_custom_notification.htm So in EasyMorph, I created the following action: However, here I can't include the first JSON level ("inputs"). At the moment this is an "Iterate...