-
-
Notifications
You must be signed in to change notification settings - Fork 319
Description
Problem
HttpRequestTask only supports sending form-style data via <postparameter/>, which limits the task to mimicking HTML form submissions. It’s not possible to send other payload types such as JSON or XML.
<target name="demo">
<http-request url="https://httpbin.org/post" method="POST">
<postparameter name="username" value="Foo"/>
<postparameter name="email" value="[email protected]"/>
</http-request>
</target>The task also provides no way to inspect or capture the server's response.
Proposed Solution
Introduce a new <payload/> element that allows sending arbitrary request bodies. This enables use cases such as webhooks, JSON APIs, and XML endpoints.
Example:
<target name="demo">
<http-request url="https://httpbin.org/post" method="POST">
<header name="Content-Type" value="application/json"/>
<payload>
{
"user": {
"id": 1024,
"name": "Foo"
},
"contact": {
"email": "[email protected]",
"phone": "+1-555-1234"
}
}
</payload>
</http-request>
</target>This also enables using bodies with methods like PUT and PATCH. Currently, <postparameter/> only works with POST and is ignored for other HTTP verbs.
Additionally, I propose adding a responseProperty attribute to store the server response in a property for later use. Please note that responseRegex and responseCodeRegex attributes already exist.
Final words
I'm ready to implement both features. Let me know if you're interested.
I'm also open to any suggestions or modifications to the proposal.
Otherwise, feel free to close the issue.