JumpKick.HttpLib — POST Requests
1. Overview of Available Request Methods (Http Static Class)
// All methods return a RequestBuilder fluent object
Http.Get(url);
Http.Post(url);
Http.Put(url);
Http.Delete(url);
Http.Patch(url);
Http.Head(url);Code language: JavaScript (javascript)
Unified fluent structure: RequestMethod().ParameterConfig().OnSuccess().OnFail().Go();
2. Two Parameter‑Passing Modes for POST
.Form(): Form submissionContent‑Type: application/x‑www‑form‑urlencoded(web‑form format).Body(): Raw payload for custom JSON / XML / SOAP messages
3. Example 1: Form Submission
using System;
using JumpKick.HttpLib;
class Program
{
static void Main(string[] args)
{
Http.Post("https://httpbin.org/post")
.Form(new
{
name = "James",
username = "j6mes"
})
.OnSuccess(result =>
{
Console.WriteLine("==== POST Form Request Succeeded ====");
Console.WriteLine(result);
})
.OnFail(webexception =>
{
Console.WriteLine("==== Request Exception ====");
Console.WriteLine(webexception.Message);
})
.Go();
Console.ReadKey();
}
}Code language: JavaScript (javascript)
4. Example 2: Submit JSON via Body
using System;
using JumpKick.HttpLib;
class Program
{
static void Main(string[] args)
{
string jsonStr = "{\"account\":\"test\",\"pwd\":\"123456\"}";
Http.Post("https://httpbin.org/post")
.Body(jsonStr, "application/json") // Payload content + media‑type specification
.OnSuccess(result =>
{
Console.WriteLine("==== POST‑JSON Request Succeeded ====");
Console.WriteLine(result);
})
.OnFail(webexception =>
{
Console.WriteLine("==== Request Exception ====");
Console.WriteLine(webexception.Message);
})
.Go();
Console.ReadKey();
}
}Code language: JavaScript (javascript)
5. Example 3: Handling a Failed POST
Intentionally target an endpoint that rejects POST to catch 405 and verify OnFail triggers
using System;
using JumpKick.HttpLib;
class Program
{
static void Main(string[] args)
{
// httpbin.org/get only accepts GET; POST yields status 405
Http.Post("https://httpbin.org/get")
.Form(new
{
test = "demo"
})
.OnSuccess(result =>
{
Console.WriteLine("==== Request Succeeded ====");
Console.WriteLine(result);
})
.OnFail(webexception =>
{
Console.WriteLine("==== Request Exception (405 caught) ====");
Console.WriteLine(webexception.Message);
})
.Go();
Console.ReadKey();
}
}Code language: JavaScript (javascript)
6. Common Error Interpretation
Error: The remote server returned an error: (405) Method Not Allowed.
Cause: The target endpoint accepts GET only and rejects POST.
Solutions:
- Switch to a POST‑capable test endpoint (httpbin.org/post recommended)
- Verify allowed HTTP methods for your target API
7. GET / POST Key Comparison Summary
| Method | Function | Parameter Style | Typical Use‑Case |
|---|---|---|---|
| GET | Http.Get() | URL query parameters | Data querying |
| POST Form | Http.Post().Form() | Form key‑value pairs | Web login, form submission |
| POST JSON | Http.Post().Body() | Raw string payload | Backend‑frontend API communication |
POST Requests
Previous: GET Requests
Next: File Upload