Skip to content

How to do a traditional POST request with form data #20

@jaredtmartin

Description

@jaredtmartin

I love your videos, and I like this tool, but I'm working with HTMX and I need to be able to do post requests with form data.
Currently I'm trying this:

        let req_login = hc.do_post(
		"/login",
		json!({
			"username": "demo1",
			"pwd": "welcome"
		}),
	);
	req_login.await?.print().await?;

But I'm getting:

=== Response for POST http://localhost:8080/login
=> Status         : 415 Unsupported Media Type Unsupported Media Type
=> Headers        :
   content-type: text/plain; charset=utf-8
   content-length: 73
   date: Thu, 01 Feb 2024 19:06:56 GMT
=> Response Body  :
Form requests must have `Content-Type: application/x-www-form-urlencoded`
===

I don't see any related examples in the docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions