>_ IzzyLab

Hands-on task

This task is step 7 of the course “curl and HTTP APIs”

Send a POST with JSON

medium~7 min

Send a POST request to http://localhost:8080/submit with the JSON body {"name":"deploy","count":3} and the header Content-Type: application/json. The server will save the received body and header — the body must be exactly this JSON.

What you'll practise:
  • curl
  • http
  • POST
  • json
  • headers

Topic breakdown

A POST request sends a body to the server; in curl, passing data automatically switches the method from GET to POST. For the server to correctly recognize the payload as JSON, you need to manually set the header Content-Type: application/json — curl doesn't adjust the content type for JSON on its own. Single quotes around the body protect the JSON's double quotes from shell interpretation.

What's checked

  1. the server received the correct JSON body
  2. the request came with Content-Type: application/json

What it looks like