Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Manoj_MUTHURAJA
Creator
Creator

Issue to extract the token from the body

Hello,

I have an issue to extract the token value from the Body.In my API Rest I am getting the body completely and I am trying to extract just the token from it but I couldn't suceed.0683p000009M8zC.png

0683p000009M9ET.pngtmap and txmlmap:0683p000009M8hz.png0683p000009M9Dl.png0683p000009M9EY.png

0683p000009M9Ed.png

As you can see the first screen capture that I am getting oneline but after it passes through composant textractxml field 0 line is inserted.As I am new to API rest in talend I don't much about the functionalities.I know there is something missing in the composant tExtractXMLField but I couldn't find it.If you have any ideas please comment it below.

Labels (4)
1 Solution

Accepted Solutions
Manoj_MUTHURAJA
Creator
Creator
Author

the token looks like this

token="IEllQMy6Qmh6VEB3EsdoNGHfU9C3eivv3Dw"0683p000009M8zo.png0683p000009M904.png

Thanks for your reply I tried it but its not working ,because it couldn't identify the column 'token'.But its okay that its not the case that token is null.

 

The output format of the body is a string.The token is never null because the I have verified in the postman as well.The issue is that the textractxml could not identify the values of the string.So I think I should make it understand the string with the xpath loop and the query xpath.

View solution in original post

7 Replies
MattE
Creator II
Creator II

I'm not too great with XML so what i tend to do in development is put a tLogRow after each step just to make sure the data looks how i expect it to look at each step. You'll probably find that the tExtractXML component isn't doing what you expect. 

rmartin2
Creator II
Creator II

Hi !

 

The easiest way to achieve that is to put your XML example in a file, and then in XMLMap, on the left pane, right-click on your entry "body", and choose "Import from File". It will build you the structure of your XML.

 

On the right pane, add a simple String field and drag-drop the attribute (it displays under your field, starting with an @ ).

 

So :

TRest =>tXMLMap=>tLogRow 

 

That's it, no need for further headache 0683p000009MACn.png

 

Sincerely,

Manoj_MUTHURAJA
Creator
Creator
Author

Thanks for your reply,

0683p000009M98R.png0683p000009M9Fb.png

I did as you proposed but how to get the elements from the body when its not recogonised in the tXMLmap composant?

or the other way could be to use the composant textractXML but I dont know exactly what to fill in the Xpath loop and in the mapping Xpath.

If you have some ideas please let me know.

Have a good day,

MattE
Creator II
Creator II

What's the format of the Body which is output from the tRest component? If token is not an XML node then the tExtractXML component won't be able to find anything. It might be better to convert the Body to a string then in a tJavaRow component strip out the token and save it to use elsewhere.

 

For example if the format of the Body was

 

token=ABC123456

 

then in a tJavaRow you could do something like this

 

//create a sting to work with
String token = ""; //check it's not null first if(!Relational.ISNULL(input_row.body) && !input_row.body.equals("")){ //get a substring from the offset of token= to the end of the string token = input_row.body.substring(input_row.body.indexOf("token=")+6, input_row.body.length()); } //put the token into a global variable to recall elsewhere globalMap.put("Token", token);
Manoj_MUTHURAJA
Creator
Creator
Author

the token looks like this

token="IEllQMy6Qmh6VEB3EsdoNGHfU9C3eivv3Dw"0683p000009M8zo.png0683p000009M904.png

Thanks for your reply I tried it but its not working ,because it couldn't identify the column 'token'.But its okay that its not the case that token is null.

 

The output format of the body is a string.The token is never null because the I have verified in the postman as well.The issue is that the textractxml could not identify the values of the string.So I think I should make it understand the string with the xpath loop and the query xpath.

Manoj_MUTHURAJA
Creator
Creator
Author

Hello,

Thanks for the solutions you have proposed me but the issue isn't solved yet.

Your solutions are still welcome.

 

Thanks in advance for your replies,

Manoj_MUTHURAJA
Creator
Creator
Author

The issue is solved.In the composant textract xml,the input to give in the loop and clolumns were corrected by myself with the help of using a metadata xml.

So I tried to create a metadata tfileinputxml with my xml content.The step before the final step of creating the metadata shows the header and other columns to be mapped in the table.

So I took the same elements it used to map in the metadata on my textract xml composant.

If you have any questions regarding this you can ask me in the comments.