0

I'm trying to use an API call to return specific information that is returned when we place a global supporter ID into a link. Then using a HTTPGet and substring combination to get the proper information.

I have the substring, HTTPGet function working well. But, I can't get it to merge in the global supporter ID into the ampscript to get the call to properly return. I'm assuming it's because AmpScript renders before the data from the data extension is available. Is there a way to do this? It works properly if I substitute the "%%ben_global_id_1%%" with an actual ben number. The %%ben_global_id_1%% is a field from my Data extension I'm previewing with.

Code is here (API call removed due to data privacy)

%%[
var @code
var @benStatus
var @index
var @index2
var @benDetails
var @FirstName
var @index3

var @addednumber

set @benStatus = HTTPGet("https://url.com/api5/qmc/ben_status/1/index.php?gid=%%ben_global_id_1%%")


set @benDetails = HTTPGet("https://url.com/api5/connects/beneficiaries/details/1/index.php?Beneficiary_GlobalId=%%ben_global_id_1%%")

set @index = indexOf(@benStatus,"code")
set @index2 = indexOf(@benDetails,"FirstName")
set @index3 =indexOf(@benDetails,"FullBodyImageURL")
set @addednumber = Add(@index2, 15)



Set @FirstName = Substring(@benDetails,Add(@index2,12),Subtract(@index3,@addednumber))
Set @code = Substring(@benStatus,Add(@index,6),3)
]%%



Full BenStatus Call:%%=v(@getRequest)=%%
<br><br>
Status Code Number:%%=v(@benStatus)=%%
<br><br>
IndexOf Code number: %%=v(@index)=%%
<br><br>
IndexOf FirstName number: %%=v(@index2)=%%
<br><br>
Full Ben Detail Call:%%=v(@benDetails)=%%
<br><br>
IndexOf FullBodyImageURL number : %%=v(@index3)=%%
<br><br>
FirstName:  %%=v(@FirstName)=%%
0

Welcome to SFSE, Victor

You have to use Concat function, when you create your URL for HTTPGet:

set @benStatus = HTTPGet(Concat("https://url.com/api5/qmc/ben_status/1/index.php?gid=",@ben_global_id_1))

Also, I don't see ben_global_id_1 being set anywhere in your code, so when using it in above Concat, I will assume it is getting set somewhere in the code, that I don't see.

To be sure you get it from your DE, I will use AttributeValue function to set it:

SET @ben_global_id_1 = AttributeValue("ben_global_id_1")
| improve this answer | |
  • Thanks for that! Very Beneficial and worked perfectly. You don't have to do a lookup when using the AttributeValue. That's nice! The only time a lookup is necessary is when you're pulling data from a seperate (one not used for the send) Data Extension, right? – Victor Miller Dec 11 '18 at 18:07
  • Correct, @VictorMiller - LookupRows is indeed only for fetching e.g. records which are referenced to the consumer, but in another DE. This could be latest purchases, favourite products or anything similar. – Lukas Lunow Dec 11 '18 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.