HTTPPostWithRetry

Similar to the HTTPPost2 function, this posts content to a defined, publicly accessible URL, but it also provides some retry options.

Arguments

HTTPPostWithRetry(1,2,3,4,5,6,7,8,[9a,9b]...)

Ordinal Type Required Description
1 String True URL endpoint used to post content
2 String True Content-Type header value
3 String True Content to include in POST request
4 Number False Number of retries. First retry is immediate, subsequent ones are delayed up to 4 seconds. Default is 3 retries.
5 Boolean False Checks if the request should be rescheduled when it cannot be completed after the set number of retry attempts. If set to true and the send fails after the specified retries, the system pauses the send and tries again after 15 minutes. If set to false, no further attempts are made to resend. The default setting is false.
6 String False Whether the process continues on an error. A value of true returns an exception.
7 String False Variable used to return status response string
8 String False Variable used to return response row set (see note)
9a String False Name of additional header to include in POST request (see note)
9b String False Value of additional header to include in POST request (see note)

NOTE: Ordinal 8 returns a row set (the number of rows varies depending on the URL). This is an internal row set and the fields are not available for use. Arguments 9a and 9b allow additional header name and value pairs to be appended as arguments — repeat these pairs as required.

NOTE: The function only works with HTTP content on TCP/IP port 80 and HTTPS on port 443. Basic access authentication in URLs is not supported (for example, https://username:password@https://domain.com).


Not a subscriber? Subscribe now.

Example

The following example makes an HTTP POST request with a JSON payload to an external endpoint.

%%[

var @payload, @postRequest, @response, @responseRows

set @payload = '{
   "Order Number":10110113,
   "First Name":"Curt",
   "Last Name":"Harris",
   "Amount":{
      "Order Subtotal":120,
      "VAT":20,
      "Shipping":0,
      "Order Total":120
   }
}'

set @postRequest = HTTPPostWithRetry("https://httpbin.org/post","application/json", @payload, 3, true, true, @response, @responseRows)

]%%
status code: %%=v(@postRequest)=%%
<br><br>response: %%=v(@response)=%%
<br><br>RowCount(@responseRows): %%=RowCount(@responseRows)=%%

Output

The request returns the status code, response payload and row set. The following response has been abbreviated for display purposes.

status code: 200

response: {"args":{}, "data":"{...}", "files":{}, "form":{  }, "headers":{...}, "json":{"Amount":{"Order Subtotal":120, "Order Total":120, "Shipping":0, "VAT":20 }, "First Name":"Curt", "Last Name":"Harris", "Order Number":10110113 } }

RowCount(responseRows): 7