For AI agents: the complete documentation index is available at /AchEngine/en/llms.txt, the full documentation bundle is available at /AchEngine/en/llms-full.txt, and this page is available as Markdown at /AchEngine/en/usage/web-request.md.

HttpLink

HttpLink wraps Unity UnityWebRequest with a builder API for GET/POST, JSON serialization, headers, and timeouts.

GET

var result = await new HttpLink.Builder()
    .SetUrl("https://api.example.com/users/1")
    .AddHeader("Authorization", "Bearer token123")
    .SetTimeout(10)
    .GetAsync<UserData>();

POST

string json = JsonConvert.SerializeObject(new LoginRequest { UserId = "abc", Password = "pw" });

bool success = await new HttpLink.Builder()
    .SetUrl("https://api.example.com/login")
    .SetJsonBody(json)
    .PostAsync();

Send directly

Use Build().SendAsync() when you need the raw response or status.

var link = await new HttpLink.Builder()
    .SetUrl("https://api.example.com/data")
    .SetMethod(UnityWebRequest.kHttpVerbGET)
    .Build()
    .SendAsync();

if (link.Success)
    Debug.Log(link.ReceiveDataString);

Builder API

MethodDescription
SetUrl(string)Request URL
SetMethod(string)GET or POST; other methods throw NotSupportedException
SetTimeout(int)Timeout in seconds
SetJsonBody(string)JSON body with application/json
AddHeader(string, string)Request header
GetAsync<T>()GET and JSON deserialize
PostAsync()POST and return success
Build()Create an HttpLink
PropertyDescription
SuccessWhether the request succeeded
ResultUnityWebRequest.Result
ReceiveDataStringResponse body as text
ReceiveDataResponse bytes
DownloadSizeDownloaded bytes
DownloadProgressProgress from 0 to 1

JSON serialization uses Newtonsoft.Json.JsonConvert.