I'm a bit lost with the HTTPPost2 function. According to the documentation, the fifth parameter is:

used to contain string representation for the status of the HTTP request, such as OK.

But this isn't the case. It returns a rowset. I'd really like to find out what the field names that are used in the rowset are, so I can view their values.

I note that depending on the URL I use for my POST request, the number of rows in the rowset changes.

Does anyone have any ideas what field values are used?

Sample Request

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

set @payload = '{  
   "Order Number":10110113,
   "First Name":"Simon",
   "Last Name":"Sausage",
      "Order Subtotal":120,
      "Order Total":120

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

status code: %%=v(@postrequest)=%%

response: %%=v(@response)=%%

responseRows: %%=v(@responseRows)=%%

responseRowCount: %%=RowCount(@responseRows)=%%

Sample Output

The request returns the status code, response payload and rowset.

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":"Simon", "Last Name":"Sausage", "Order Number":10110113 } }

responseRows: System.Data.DataRow[]

responseRowCount: 10

1 Answer 1


I Guess the Platform.Function.ParseJSON(); will do the trick! Not sure what is expected here, but as per my below code I able to get the desired token from the rowset received.

<!-- Processing page : START -->
   /*Generating the AccessToken using client id and secret key*/
   VAR @callstatus, @response
   SET @payload = '{"client_id": "xxxxx", "client_secret": "xxxxxx", "grant_type": "client_credentials"}'
   SET @accessToken = HTTPPost2("https://xxxxxxx.auth.marketingcloudapis.com/v2/token", "application/json", @payload, True, @callstatus, @response)

<script runat="server">
/*Framing the API content and extracting only access token from the above "@callstatus" */
   Platform.Load("core", "1");

   var accessTok = Variable.GetValue("@callstatus");
   var response_ = Platform.Function.ParseJSON(accessTok);
   var accessToken_ = response_.access_token;

   Variable.SetValue("@token_",'Bearer '+accessToken_); 


 Callstatus   =   %%=v(@callstatus)=%% 
 accessToken_   =    %%=v(@accessToken_)=%% 
 token_   =   %%=v(@token_)=%% 
<!-- Processing page : END -->

Note: Kindly replace Client ID, Client secrete and subdomain in URL

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .