Quantcast
Channel: Active questions tagged ampscript - Salesforce Stack Exchange
Viewing all articles
Browse latest Browse all 359

Calling an External API using AMPscript in SMS Asset. Unable to reference Columns from Data Extension in Payload

$
0
0

I have the following codesnippet which I reference as content block by key in my SMS Asset. Unfortunately I am not able to get the price from the API. How do I make the payload dynamic such that it takes in values from my Data Extension to post to the API and fetch the price for the combination

%%[Var @callStatus, @callStatusrowset, @payload, @headername, @headervalue, @request, @rows, @priceRow, @price, @drug_id, @drg_qty, @pharmacy_idSET @drug_id = Lookup("TableName", "drug_id", "SubscriberKey", _subscriberkey)SET @drg_qty = Lookup("TableName", "drug_quantity", "SubscriberKey", _subscriberkey)SET @pharmacy_id = Lookup("TableName", "pharmacy_id", "SubscriberKey", _subscriberkey)SET @payload = Concat('{"drug_id":"',@drug_id,'","quantity":"',@drg_qty,'","pharmacy_id":"',@pharmacy_id,'"}')SET @headername = "Header Name"SET @headervalue = "HeaderValue"SET @request = HTTPPost2("Endpoint.com/v4", "application/json", @payload, false, @callStatus, @callStatusrowset, @headername, @headervalue)IF (@request == 200) THEN  SET @rows = BuildRowsetFromJSON(@callStatus, "$.['prices'][*]", 1)  SET @priceRow = Row(@rows,1)  SET @price = Field(@priceRow,'price')  ]%%  The discounted price of %%=V(@price )=%%.   %%[ELSEIF (@request == 404) THEN  SET @price = "Coupon not found"  ]%%  Sorry, the coupon is not available%%[ENDIF]%%

Viewing all articles
Browse latest Browse all 359

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>