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
🌐
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 });
🌐
Atlassian
developer.atlassian.com › server › crowd › json-requests-and-responses
JSON requests and responses
curl -i -u application_name:application_password --data '{"value": "my_password"}' http://localhost:8095/crowd/rest/usermanagement/1/authentication?username=my_username --header 'Content-Type: application/json' --header 'Accept: application/json' ... { "reason" : "INVALID_USER_AUTHENTICATION", ...
Discussions

android - How to build JSON Request Body? - Stack Overflow
I'm trying to build the following JSON Request Body. It's my first time with JSON and I'm following this examples, but still struggling. I've been taking a look to GSON but wanted to manage pure ... More on stackoverflow.com
🌐 stackoverflow.com
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
🌐 forum.uipath.com
18
2
March 23, 2021
php - POST request with JSON body - Stack Overflow
I would like to add a post to a Blogger blog via PHP. Google provided the example below. How to use that with PHP? You can add a post for a blog by sending a POST request to the post collection URI with a post JSON body: More on stackoverflow.com
🌐 stackoverflow.com
API REST POST Request body in JSON is treated as string
I've been trying to setup a POST request in my REST API; however I'm having an issue with the body I send on the request; the body contains a nested object, but the payload is always sent as a string; I've followed the steps mentioned in this article: Perform REST API requests But the same ... More on community.retool.com
🌐 community.retool.com
0
0
March 8, 2024
🌐
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...
🌐
FastAPI
fastapi.tiangolo.com › tutorial › body
Request Body - FastAPI
For example, this model above declares a JSON "object" (or Python dict) like:
🌐
Postman
postman.com › postman › postman-team-collections › request › ii8syuh › using-json-request-body
Using JSON request body | Working with GraphQL | Postman API Network
postman request POST 'https://swapi.apis.guru' \ --header 'Content-Type: application/json' \ --body '{ "query" : "query { allFilms { films { id title episodeID } } }" }'
🌐
ReqBin
reqbin.com › req › 4rwevrqh › post-json-example
How do I post JSON to the server?
January 16, 2023 - 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 ...
Find elsewhere
🌐
Apidog
apidog.com › articles › send-json-object-with-post-request
How to Send JSON Object with POST Request
April 30, 2024 - Navigate to the "Body" tab, choose "json." Notably, you do not need to set the Content-Type header to application/json in Apidog; simply input your JSON data in the provided text box.
🌐
ReqBin
reqbin.com › req › v0crmky0 › rest-api-post-example
How do I post JSON to a REST API endpoint?
To post JSON to a REST API endpoint, you must send an HTTP POST request to the REST API server and provide JSON data in the body of the POST message. You must also specify the data type using the Content-Type: application/json request header.
🌐
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.
🌐
UiPath Community
forum.uipath.com › help › studio
Adding Json Body to a HTTP request - Studio - UiPath Community Forum
March 23, 2021 - 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”, “where”: { "TriggerHoursUpdate": "True" } } Code I tried:- “{ “”“type””“: “”“Select””“, “”“Where””“: { “”“TriggerHoursUpdate””“: “”“True””" }“}” Could anyone advise on how to do this?
🌐
Baeldung
baeldung.com › home › http client-side › making a json post request with httpurlconnection
Making a JSON POST Request With HttpURLConnection | Baeldung
May 11, 2024 - In this article, we learned how to make a POST request with JSON content body using HttpURLConnection.
Top answer
1 of 5
153

You need to use the cURL library to send this request.

<?php
// Your ID and token
$blogID = '8070105920543249955';
$authToken = 'OAuth 2.0 token here';

// The data to send to the API
$postData = array(
    'kind' => 'blogger#post',
    'blog' => array('id' => $blogID),
    'title' => 'A new post',
    'content' => 'With <b>exciting</b> content...'
);

// Setup cURL
$ch = curl_init('https://www.googleapis.com/blogger/v3/blogs/'.$blogID.'/posts/');
curl_setopt_array($ch, array(
    CURLOPT_POST => TRUE,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_HTTPHEADER => array(
        'Authorization: '.$authToken,
        'Content-Type: application/json'
    ),
    CURLOPT_POSTFIELDS => json_encode($postData)
));

// Send the request
$response = curl_exec($ch);

// Check for errors
if($response === FALSE){
    die(curl_error($ch));
}

// Decode the response
$responseData = json_decode($response, TRUE);

// Close the cURL handler
curl_close($ch);

// Print the date from the response
echo $responseData['published'];

If, for some reason, you can't/don't want to use cURL, you can do this:

<?php
// Your ID and token
$blogID = '8070105920543249955';
$authToken = 'OAuth 2.0 token here';

// The data to send to the API
$postData = array(
    'kind' => 'blogger#post',
    'blog' => array('id' => $blogID),
    'title' => 'A new post',
    'content' => 'With <b>exciting</b> content...'
);

// Create the context for the request
$context = stream_context_create(array(
    'http' => array(
        // http://www.php.net/manual/en/context.http.php
        'method' => 'POST',
        'header' => "Authorization: {$authToken}\r\n".
            "Content-Type: application/json\r\n",
        'content' => json_encode($postData)
    )
));

// Send the request
$response = file_get_contents('https://www.googleapis.com/blogger/v3/blogs/'.$blogID.'/posts/', FALSE, $context);

// Check for errors
if($response === FALSE){
    die('Error');
}

// Decode the response
$responseData = json_decode($response, TRUE);

// Print the date from the response
echo $responseData['published'];
2 of 5
13

I think cURL would be a good solution. This is not tested, but you can try something like this:

$body = '{
  "kind": "blogger#post",
  "blog": {
    "id": "8070105920543249955"
  },
  "title": "A new post",
  "content": "With <b>exciting</b> content..."
}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Authorization: OAuth 2.0 token here"));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$result = curl_exec($ch);
🌐
Retool
community.retool.com › 💬 queries and resources
API REST POST Request body in JSON is treated as string - 💬 Queries and Resources - Retool Forum
March 8, 2024 - I've been trying to setup a POST ... sent as a string; I've followed the steps mentioned in this article: Perform REST API requests But the same ......
🌐
Reddit
reddit.com › r/htmx › how to send a json in the request body using htmx ?
r/htmx on Reddit: How to send a Json in the request body using HTMX ?
January 29, 2025 -

Hi all, I am trying to create a button that will send a request to server with a Json in the body. But i keep getting the json as FORM in the request while the body is empty. I read that we need json-enc extension for sending the json is body so i did use that still the same issue. What am i doing wrong. Here is the button code.

<button hx-post="/userManagement/updateUserState"
        hx-ext="json-enc"
        hx-vals='{"users": ["{{.Email}}", "testing@yoyo.com"]}'
        class="button is-danger is-rounded">Disable</button>

{"users":"testing@yoyo.com","csrf":"AtouXBVbEupRVSzHwhUXrzzSwlJoLhNv"}

This is the request payload when sent. and i get bad request error. please point out what i am doing wrong thanks.

🌐
Redocly
redocly.com › learn › openapi › openapi-visual-reference › request-body
Request Body Object
May 28, 2025 - The following example shows a request body. paths: /results: post: summary: Submit Chess Results operationId: postChessResult requestBody: required: true description: This is my test description. content: application/json: schema: $ref: ...
🌐
ReqBin
reqbin.com › req › 2xhbguy8 › json-payload-example
How do I send JSON Payload to the server?
January 13, 2023 - To send the JSON payload to the server, you need to enclose the JSON data in the HTTP request body and indicate the data type of the request body with the "Content-Type: application/json" request header.
🌐
Tableau
help.tableau.com › current › api › rest_api › en-us › REST › rest_api_concepts_example_requests.htm
REST API Example Requests - Tableau
If the examples shows a POST or PUT request, there's a blank line, followed by the XML information that's included in the body. The first REST API request in a session must be a sign-in request. This is a POST request that sends the user credentials in the body of the request. Because this is a POST request, the request must include the Content-Type header. You can send your the body of the request block as XML or JSON...