Runtime verified Differs from official docs Test scripts included

Syntax

HTTPPostWithRetry(urlEndpoint, contentTypeHeader, content[, numRetries, reschedule, returnExceptionOnError, @responseStatus, @responseContentRowset, headerName1, headerValue1, ...])  →  number

Parameters

Name Type Required Description
urlEndpoint string Yes The URL to post the content to
contentTypeHeader string Yes The Content-Type header for the request
content string Yes The content to send in the POST body
numRetries number No How many times the request can be retried (default 3)
reschedule string | boolean | number No When truthy, retry after 15 minutes if all retries fail (default false). Accepts true, false, 1, 0, "true", "false", "1", "0"; because the retry is 15 minutes out, a single request cannot show the truthy and falsy spellings behaving differently
returnExceptionOnError string | boolean | number No When truthy, a failed request aborts the page; when falsy, the page continues and the status is available for inspection. Accepts true, false, 1, 0, "true", "false", "1", "0"
responseStatus string No Output variable that receives the response body
responseContentRowset rowset No Output variable that receives the response headers as a rowset
headerName1 string No Name of an additional request header
headerValue1 string No Value of an additional request header

There is no upper bound on the argument count — additional request headers are passed as repeated name/value pairs after the rowset variable.

Example

%%[ VAR @status, @body, @headers
  SET @status = HTTPPostWithRetry("https://postman-echo.com/post", "application/json", '{"marker":"amp-retry-xx7"}', 2, false, true, @body, @headers)
]%%
%%=v(@status)=%%

Renders 200; @body holds the echoed response and @headers is a rowset of the response headers.

Lower the retry count and let the function raise on a persistent failure:

%%[
  VAR @status, @body, @headers
  SET @status = HTTPPostWithRetry("https://postman-echo.com/post", "application/json", @payload, 2, false, true, @body, @headers)
]%%
Status %%=v(@status)=%%; header rows %%=v(RowCount(@headers))=%%

Return value

number — the HTTP status code of the response, which is 200 on a successful POST. There is no closed set of values to test for a success.

Behaviour

The responseStatus argument holds the body, and a separate rowset holds the headers. The official reference labels the argument as storing the request “status”, but at runtime it receives the response body (289 characters of echoed JSON) while responseContentRowset receives the response headers as a rowset. The layout matches HTTPPost2. See the differs-from-docs note.

returnExceptionOnError decides a failed request; reschedule is not observable. All eight boolean-like literals are accepted for returnExceptionOnError, and against a 404 endpoint a truthy value aborts with HTTP 422 while a falsy value continues at HTTP 200 with the response status captured as 404. A transport failure aborts the page regardless of the flag, so a 404 endpoint — not a host that does not resolve — is what tells a truthy value from a falsy one. reschedule accepts the same eight spellings, but its documented effect is a retry 15 minutes out, so a single request cannot distinguish the truthy from the falsy forms: read them as accepted spellings, never as interchangeable behaviour. A normal POST to a healthy endpoint still returns 200.

The HTTP status code is the return value. As with the other POST functions, the numeric status comes back as the function’s own return value, not through an output variable.

Show test script
%%[
  VAR @b, @s3, @body3, @rr3
  SET @b = RequestParameter("b")
  OutputLine(Concat("CTRL=[", Uppercase("ok"), "]"))

  /* 8-arg form: numRetries/reschedule/returnExceptionOnError accepted; @body3 the body, @rr3 the header rowset. fetch ?b=retry */
  IF @b == "retry" THEN
    SET @s3 = HTTPPostWithRetry("https://postman-echo.com/post", "application/json", '{"marker":"amp-retry-xx7"}', 2, false, true, @body3, @rr3)
    OutputLine(Concat("status=[", @s3, "] bodylen=[", Length(@body3), "]"))
    OutputLine(Concat("rrRows=[", RowCount(@rr3), "]"))
  ENDIF
]%%

Availability

Platform Available
Marketing Cloud Engagement Yes
Marketing Cloud Next No

See also