Solved

FSM Integration with XMLOutboundConnector still returns json data

  • 20 May 2021
  • 8 replies
  • 344 views

Userlevel 4
Badge +9
  • Sidekick (Partner)
  • 59 replies

Hi Experts,

I’m trying to make a simple rest api call to an authentication endpoint and retrieve token information. Initially I tried this with the JsonOutboundConnector, which retrieves the response as following, 

 


As you can see the response is in json. I couldn’t successfully capture this response and extract only the access token for use in subsequent calls. This issue was raised here

Since then I got in contact with the resource owners and got them to send the response in xml, which would make it possible for me to use the XmlOutboundConnector and extract the access token. This works fine in postman,

The only thing I had to do additionally was to add the following header,  Accept = application/xml (without this header it returns json)


Although, when I try the same in FSM I still end up getting the response in json 

 


It’s as if the Accept header is not considered at all? or am I missing something else?

​​​​​​​Any help is greatly appreciated.​​​​​​​

icon

Best answer by Saranga Amaraweera 24 May 2021, 17:46

View original

This topic has been closed for comments

8 replies

Userlevel 7
Badge +22

Hi @Miraj ,

 

Can you check whether you have correctly added the inbound XML Map with XML declaration in the Details tab?

Userlevel 4
Badge +9

@Saranga Amaraweera 

In the map, I had  “Extract XML Declaration” unticked. I just ticked that (refreshed cache) and tried again.
Still I get the following json back (now you can see the xml declaration bit is added in the transaction input)

 

 

Userlevel 7
Badge +24

Hi @Miraj,

Can you try setting the accept to be equal to the content-type i.e. text/xml?

This will hopefully stop it interpreting the response as JSON.

Kind regards,

Lee Pinchbeck

Userlevel 4
Badge +9

@Lee Pinchbeck

Made that change and tried, still returns the same

 

 

Userlevel 7
Badge +22

Hi @Miraj ,

 

Could you kindly share the screenshots of your inbound map and how it has been called in your outbound message?

Userlevel 4
Badge +9

@Saranga Amaraweera @Lee Pinchbeck 

Following is the map I use to make the auth call (I’m using request as a dummy primary table for the moment)


The routing setup
 


How I plan to capture the token (from an xml response)
 


 


How I make the call
 


what’s now happening

 

 

 

Userlevel 7
Badge +22

Hi @Miraj ,

 

Sorry for the delayed response, isn’t is possible for you to update the custom application parameter with the inbound map’s Response Maps Parameters section instead of the XML message?  Something similar to below?

Also can you remove Accept:xml; section from the HTTP Header in the routing rule?

Ideally there should be 2 XML maps if I’m not mistaken here. 1st one is to proceed with the message routing rule to request the token along with processing with your outbound message updates and then the second one is the inbound xml map to update the custom app params when the response is received. Here you have created only one map?

Userlevel 4
Badge +9

@Saranga Amaraweera 

I feel like there’s a bug in the system when it comes to accepting multiple headers. I’ve reported a case on this. In the meantime I managed to get the resource owner to send an xml response for the token without being contingent on a header. Once I receive the response which looks like following,
 


I managed to extract the token and update the cust app params using a function,

 

 


This gets the job done for now. I appreciate your suggestion of using two maps(another map for processing the response), which I believe is the correct way to go about if the response is a complex one which requires some processing.
Thanks a lot!