Retrieve response from REST API | Community
Skip to main content
Adobe Champion
August 7, 2017
Solved

Retrieve response from REST API

  • August 7, 2017
  • 18 replies
  • 10725 views

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!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

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.

18 replies

Adobe Employee
August 8, 2017

Assuming the .data property of the guideResultObject is empty?

Adobe Champion
August 8, 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.

Adobe Champion
August 8, 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]

Adobe Employee
August 8, 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.

Adobe Champion
August 8, 2017

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

Adobe Champion
August 10, 2017

lesutton1,

Any further thoughts? 

smacdonald2008
smacdonald2008Accepted solution
August 10, 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.

Adobe Champion
August 11, 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).