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

Retrieve response from REST API

Avatar

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
joshuau83969408
Level 2

07-08-2017

When using an adaptive form, is it possible to retrieve the response from the rest service I'm invoking?  My adaptive form is invoking a sling servlet which then invoked my 3rd party rest api.  The rest api is returning a payload but I'm unable to access the payload when looking at the guideResultObject that is returned.  Any pointers would be helpful.

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

10-08-2017

So in the object that is returned - you are not seeing the data correct?

"It doesn't have the response in the data property"

Looks like a bug - i recommend opening a bug and report this. ANother apprach you can take is to write the form as an HTL component and then use WCMUsePojo and call the service. Then you can update your form fields with the returned data set.

Answers (17)

Answers (17)

Avatar

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
joshuau83969408
Level 2

11-08-2017

That's correct.  I'll open a Daycare ticket.  Unfortunately for this effort, we need to use Adobe Forms (assuming it works as expected).

Avatar

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
joshuau83969408
Level 2

09-08-2017

lesutton1,

Any further thoughts? 

Avatar

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
joshuau83969408
Level 2

08-08-2017

You could see below the guideResultObject being returned.  It doesn't have the response in the data property.

console.png

Avatar

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct Reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct Reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile
lesutton1
Level 3

08-08-2017

Can you debug further and take a look at what the object is that is in your data? Sounds like instead of straight XML you're getting an object with more than one message in it.

Avatar

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
joshuau83969408
Level 2

08-08-2017

Correct, when I add this console.log: console.log('guideResultObject.data: ' + guideResultObject.data);, the following prints in Chrome's console:

guideResultObject.data: [object Object]

Avatar

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
joshuau83969408
Level 2

08-08-2017

Yes.  The adaptive form is invoking a Sling Servlet, which is then calling my 3rd party service.  I'm looking to surface the response of the 3rd party service in my window.guideBridge.submit success callback function.

Avatar

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct Reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct Reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile
lesutton1
Level 3

08-08-2017

Assuming the .data property of the guideResultObject is empty?

Avatar

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
joshuau83969408
Level 2

08-08-2017

My REST service is returning JSON.  Here is the response I'm logging in my Sling Servlet.  I want to be able to acccess the leadId in the success callback handler.

{"status":"OK","encoding":null,"data":{"leadId":"3dc2eb71-d40a-4bdd-a16d-510636098b1d"},"apiErrorList":null}

Avatar

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct Reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct Reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile
lesutton1
Level 3

08-08-2017

it should contain any error messages but is your rest call taking place server side? i.e.: you're populating the response object and looking for those results in your form?

Avatar

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
joshuau83969408
Level 2

08-08-2017

lesutton1,

We are on 6.2  I'm using the submit button click rules and I have the following.  Shouldn't my REST service response come back in the guideResultObject? It's null when I try logging it.

window.guideBridge.submit({

    validate: true,

    error : function (guideResultObject) {

        handleErrorSubmission("There was an error.  Please try again later.");

    },

    success : function (guideResultObject) {

        console.log('guideResultObject: ' + guideResultObject);

        console.dir('guideResultObject: ' + guideResultObject);

        var msg = guideResultObject.getNextMessage();

        while (msg != null) {

            console.error(msg.message);

            msg = guideResultObject.getNextMessage();

        }

    }

})

Avatar

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct Reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct Reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile
lesutton1
Level 3

08-08-2017

What format is your REST service returning and what are you trying to pre-fill? (then can provide appropriate sample)

Avatar

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
joshuau83969408
Level 2

08-08-2017

Thanks Scott but that link looks like it's for invoking SOAP based services where as I'm invoking a REST based service.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

08-08-2017

Avatar

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct Reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct Reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile
lesutton1
Level 3

08-08-2017

If you are using 6.3 then you can use the new data feature to build this into your form. However, if you're on 6.2 or are just more familiar with JavaScript, then simply write an AJAX call in a client library (or in the rules but not ideal) to make the call for you. Then use the AF API's to update the form and form data that you need from your JSON response.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

08-08-2017

I have never tried that use case with an Adaptive form. I am asking other ppl within Adobe if this is the case.

Avatar

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
joshuau83969408
Level 2

Likes

5 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
joshuau83969408
Level 2

08-08-2017

Scott,


Do Adaptive Forms not support retrieving the rest response in the guideResultObject?  Also, I'm using AEM 6.2.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

08-08-2017

The only thing i can think of for this is to write a custom component for use in an Adaptive form. Then invoke the 3rd party Restful service and get back the data and write the results to the form.

We have a use case for AEM and 3rd party Restful service - however - its using HTL component -not an adaptive form.

Scott's Digital Community: Creating an AEM HTML Template Language Component that displays data from ...