Skip to content

System.Net.Http

reference
1 min readUpdated

Kind: Service

Source: Pams/Logic/Pams.Business/Pams.Business.csproj (line 1)

Part of: Pams

NuGet package dependency

System.Net.Http is a NuGet package dependency declared in Pams.Business.csproj. It supports outbound HTTP requests from Pams business logic, such as calling external APIs through HttpClient.

Diagram

mermaid
sequenceDiagram
    participant Business as Pams.Business
    participant HttpClient as System.Net.Http
    participant Api as External API

    Business->>HttpClient: Create request
    HttpClient->>Api: Send HTTP request
    Api-->>HttpClient: Return HTTP response
    HttpClient-->>Business: Return response content

Usage

ts
async function loadCustomer(customerId: string) {
  const response = await fetch(`/api/customers/${customerId}`);

  if (!response.ok) {
    throw new Error(`Customer request failed: ${response.status}`);
  }

  return response.json();
}

const customer = await loadCustomer("customer-id");
console.log(customer);

AI Coding Instructions

  • Keep outbound HTTP calls in the business or integration layer rather than UI code.
  • Reuse configured HttpClient instances instead of creating a client for each request.
  • Check response status codes before reading response content.
  • Handle network failures and cancellation when calling external endpoints.
  • Keep external API request and response models separate from internal business models.

Was this page helpful?

Download as PDF