Skip to content

httpRequest

httpRequest(url: string, init: HttpRequestInit): Promise<HttpResponse>

Sends an HTTP request to any URL, with optional retries and backoff.

Sends no UiPath authentication — it targets third-party endpoints. A non-2xx status resolves with ok: false instead of throwing; only a request that never reached the server throws.

Parameters

Parameter Type Description
url string Absolute URL to send the request to
init HttpRequestInit Method, headers, body, query parameters, timeout, and retry behavior

Returns

Promise<HttpResponse>

An HttpResponse. data is unknown — narrow it after checking ok.

Examples

import { httpRequest } from '@uipath/uipath-typescript/core';

const response = await httpRequest('https://api.example.com/v1/orders');
if (response.ok) {
  console.log(response.data);
} else {
  console.log('Request failed with status', response.status);
}
import { httpRequest } from '@uipath/uipath-typescript/core';

// POST with retries, which are off for non-idempotent methods by default
const response = await httpRequest('https://api.example.com/v1/orders', {
  method: 'POST',
  headers: { 'x-api-key': '<apiKey>' },
  body: { sku: 'ABC-123', quantity: 2 },
  timeoutMs: 10000,
  retry: {
    maxRetries: 4,
    initialDelayMs: 1000,
    backoffStrategy: 'linear',
    retryMethods: ['GET', 'HEAD', 'POST']
  }
});

if (response.ok) {
  const order = response.data as { id: string };
  console.log(response.status, order.id);
}