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
BedrockMission!

Learn More

View all

Sign in to view all badges

Call API Runtime in ACS

Avatar

Avatar
Level 1
aurélienh561651
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
aurélienh561651
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile
aurélienh561651
Level 1

05-11-2020

Hi,

 

I am trying to create an API in Runtime, and call it in ACS.

Javascript action's is :

function main(params) {
	for (var i=0; i < params.count; i++) {
   
        return new Promise (function (resolve, reject) {
            
			var resp = {
				statusCode: 200,
				headers: {
					'Content-Type': 'application/json'
				},
				body: {msg:  'Hello' + params.firstname}
		   };
           resolve(resp);			
        });
		
    }
}

 

In ACS, I have a workflow and I target 10 contacts.

For theses contacts,  I would like call my API, and recover "Hello <firstname>" as result.

aurélienh561651_1-1604602883896.png

aurélienh561651_2-1604602946584.png

 

aurélienh561651_3-1604603010919.png

 

This workflow fail, and I got the error below (but no more details....) :

aurélienh561651_4-1604603124652.png

 

What is wrong ? Can you help me on this subject ?

 

Thank you,

Regards,

Aurélien

 

 

 

 

 

 

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 1
keilorblend360
Level 1

Likes

0 likes

Total Posts

9 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
keilorblend360
Level 1

Likes

0 likes

Total Posts

9 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
keilorblend360
Level 1

05-11-2020

Hard to tell what your end result is meant to be, but you can't "return" multiple times in a single function. If you're wanting 10 responses of "Hello <firstName>", you'll need to call the function 10 times.

Also, if your action is a web action and is invoked by a web service, the params object contains a lot more information than just the parameters you're passing into the function.