Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
nivedhitha
Creator III
Creator III

Parse an XML response from tRest in 2 different ways depending on the same XML

Hi,

 

My situation is this. Im making an API call and getting an XML response. Depending on whether it is a successful response or failure response I want to extract different fields. the success response is in the below format and I want to extract FILE_PATH from here.

<Envelope>

<Body>

<RESULT>

<SUCCESS>TRUE</SUCCESS>

<JOB_ID>13681777</JOB_ID>

<FILE_PATH>/download/Test Contact X - All - Dec 21 2018 06-29-31 PM.CSV</FILE_PATH>

</RESULT>

</Body>

</Envelope>

 

And the failure response is this and I want to extract FaultString from here

 

<Envelope>

    <Body>

    <RESULT>

        <SUCCESS>false</SUCCESS>

    </RESULT>

    <Fault>

        <Request/>

        <FaultCode>invalid_token</FaultCode>

        <FaultString><![CDATA[The access token is invalid. Token provided was: aYrVV8SyBUoXvXn8USth/]]></FaultString>

        <detail>

            <error>

                <errorid>145</errorid>

                <module/>

                <class>SP.Admin</class>

                <method/>

            </error>

        </detail>

    </Fault>

    </Body>

</Envelope>

 

When I use tExtractXMLField to do this , the Loop XPath query and Path query has to be different for different response.

when it is a successful callI have to assign the FILE_PATH to a context variable and continue.When it is an error response I have to stop the processing(tDie) and add assign the FaultString as the error msg in tDie.

 

Does anyone have any thoughts/suggestions about this?

Please help me with this. I tried several different ways but could never accomplish this. Looking forward for some inputs from you guys.

 

Thanks !!

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi,

 

    The first step will be to capture the response details to a context variable (success and failure). Then based on the failure condition (using an if condition), you can pass the corresponding context variable to down stream flow. You will have to create two flows here to parse the response i.e. one for success flow and other for failure flow.

 

    Then you will be able to parse them using tXMLMap components since you are managing them through two different flows.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

1 Reply
Anonymous
Not applicable

Hi,

 

    The first step will be to capture the response details to a context variable (success and failure). Then based on the failure condition (using an if condition), you can pass the corresponding context variable to down stream flow. You will have to create two flows here to parse the response i.e. one for success flow and other for failure flow.

 

    Then you will be able to parse them using tXMLMap components since you are managing them through two different flows.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂