Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

The 4th edition of the Campaign Community Lens newsletter is out now!

HttpClientRequest not working properly when using Keep Alive

Avatar

Level 2

Hello,

i used the example in the doc (Keep Alive example) https://docs.adobe.com/content/help/en/campaign-classic/technicalresources/api/c-HttpClientRequest.h...

to implement it in my real case.

i have an array with 50 json object that i want to insert in a DB using an external API , this is my code : 

 

      var apiRequest = new HttpClientRequest("www.myAPI.com");
      
      apiRequest.method = "POST";

     // open the connection with my api
    apiRequest.connect();
	
		// loop through my array to insert each element. 50 calls ?

		for each(var contactObj in myArray){
		  
		  var jsonObject = myMethodtoconstructMyObj(contactObj); 
		  
		  apiRequest.body = jsonObject;
		  
		  // here normally should call the API with POST and my jsonObject in the request body
		  apiRequest.execute();

		  }
  
  apiRequest.disconnect();

 

But when i check my backend i found that the api is called only once (instead of 50) and i found only one element inserted.

 

could you please guide me what's the wrong with my code.

 

Regards !

 

@Jonathon_wodnicki 

0 Replies

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now