>_ IzzyLab

Hands-on task

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

POST a urlencoded form

medium~5 min

Send a POST request to http://localhost:8080/submit as a form (application/x-www-form-urlencoded) with the field name set to John & Co+1 (with spaces, & and +). The server replies with the value it got after parsing the form.

What you'll practise:
  • curl
  • --data-urlencode
  • POST
  • form-urlencoded
  • encoding

Topic breakdown

The application/x-www-form-urlencoded format encodes form fields as name=value&name2=value2, with special characters (space, &, =, +) replaced by %XX. The curl --data-urlencode 'name=value' option encodes the value itself, sets the right Content-Type and switches the request to POST — unlike -d/--data, which sends the data as is and breaks on special characters. It's a reliable way to pass user input to legacy forms and APIs that don't accept JSON.

What's checked

  1. the name field was received intact

What it looks like