October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Send a URL with `Content-Type: text/uri-list` in JavaScript

Use `text/uri-list` when an API expects URIs as plain-text body data. The fetch URL remains the destination; the body carries the submitted URI list.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To send a URL as data in a JavaScript fetch() request, put it in the request body and set Content-Type to text/uri-list—but only if the receiving endpoint expects that format. The URL in fetch()‘s first argument is the request destination; it is not the URL being submitted.

Send a URL as a URI-list body

A text/uri-list payload is plain text containing one URI per line. For a single URL, the request can look like this:

const response = await fetch("https://api.example.com/submit", {
  method: "POST",
  headers: { "Content-Type": "text/uri-list" },
  body: "https://example.com/resourcern",
});

This is a format example, not a tested request to a real API: api.example.com is illustrative. Use the method, endpoint, and payload format documented by your API. Some endpoints may expect JSON or another content type instead.

Keep the destination separate from the submitted URL

These parts of the request do different jobs:

  • fetch("https://api.example.com/submit", ...) selects the endpoint that receives the request.
  • body carries the submitted URL as data.
  • Content-Type describes the format of that body.

If you want to retrieve a page rather than submit its address to an API, use that page’s URL as the fetch() destination. For example, fetch("https://example.com/resource") requests that resource; it does not send the address as a text/uri-list body.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Format one or more URIs correctly

RFC 2483 defines text/uri-list as a simple format for lists of URLs and URNs intended for automatic processing. Put each URI on its own line and terminate lines with CRLF (rn). Lines beginning with # are comments, so do not begin a URI with # to represent its fragment.

For multiple URLs, join the entries with CRLF and include a final CRLF:

const uriList = [
  "https://example.com/first",
  "https://example.com/second",
].join("rn") + "rn";

const response = await fetch("https://api.example.com/submit", {
  method: "POST", // Use the method documented by the endpoint.
  headers: { "Content-Type": "text/uri-list" },
  body: uriList,
});

RFC 2483 specifies the format and security considerations in RFC 2483. MDN explains how the URL argument, request body, and headers work in its Fetch API guide.

Check the endpoint contract before sending

The media type alone does not determine whether a request will succeed. Verify the API documentation for its required HTTP method, accepted content types, authentication, CORS behavior, and rules for validating submitted URIs. The example above cannot establish those endpoint-specific details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Validate URIs before automatic processing

A submitted URI list is untrusted input. If a server or client will automatically retrieve the listed destinations, validate the allowed schemes and destinations first. RFC 2483 warns that dereferencing entries can expose confidential locations or trigger consequential actions; see its security considerations.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Do not confuse this with a javascript: URL

JavaScript code can call fetch() and set an HTTP header through the request options. A javascript: URI is instead a navigation target that runs code; it is neither a content type nor a way to set request headers. MDN describes JavaScript URLs and the structure of URI schemes.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.