Skip to main content
Files:
  • Packages/com.molca.core/Runtime/Networking/Http/HttpClient.cs
  • Packages/com.molca.core/Runtime/Networking/Http/HttpRequestAsset.cs

When to use

  • HttpRequestAsset (recommended) — for data-driven endpoints where URL, method, headers, and body templates live in a ScriptableObject. Best for stable API calls configured once in the Inspector.
  • HttpRequestBuilder (programmatic) — for dynamic endpoints or when URL/body must be built at runtime. Uses a fluent builder API.
  • Both route through the same HttpClient subsystem with queuing, concurrency control, and connection error events.

HttpClient

RuntimeSubsystem — async HTTP with request queuing, auth header management, and event hooks.
⚠️ The static HttpClient.* API is deprecated. All static members (SendAsync, Send, CreateRequest, BaseUrl, events, etc.) are marked [Obsolete]. Use the IHttpClient instance interface instead:
Or inject via [Inject] IHttpClient http;
Events: RequestStarted, RequestCompleted, RequestFailed, ConnectionError (instance event Action).

Legacy static API (deprecated)

The following static members on HttpClient still compile but are [Obsolete] — migrate to the IHttpClient instance pattern above.

HttpRequestAsset

ScriptableObject describing URL, method, headers, and body templates. Create via Molca → Networking → HTTP Request.

Code

From a HttpRequestAsset (recommended when the request is mostly data-driven):
Programmatic requests using the fluent builder (preferred — uses IHttpClient):

API Reference

IHttpClient (instance API)

See the IHttpClient table above. Resolve via:

HttpRequestAsset

HttpRequestBuilder

Troubleshooting

  • Request fails silently: subscribe to HttpClient.OnRequestFailed or OnConnectionError for diagnostics. The request may have been queued but not started if MaxConcurrentRequests is exceeded.
  • Auth header missing on requests: call HttpClient.AddDefaultHeader("Authorization", "Bearer " + token) after login. Default headers are applied to all future requests automatically.
  • Wrong base URL: BaseUrl comes from HttpModule on Global Settings. If the module is missing, URLs must be absolute (set useFullUrl = true or use FullUrl() on the builder).
  • Request validation fails: HttpRequestAsset.Validate(out errors) will return false if the URL is empty or malformed. Check the errors array for specifics.

Unity Editor

Http Request Asset Inspector

HttpRequestAsset — endpoint definition in Inspector