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: 
modara
Creator
Creator

API data to talend open studio

Hi there,

I am trying to get API calendar data to JSON format , here the configuration i have done. but it gives me error

in trestclient configuration,

0695b00000htMEbAAM.png

in textractjsonfield configation

0695b00000htMEqAAM.png

in textractjsonfield i eidt schema and do this,

0695b00000htMF5AAM.png

error i got,

Starting job calendar_API_Test at 08:55 31/05/2023.

[statistics] connecting to socket on port 3731

[statistics] connected

Could not parse token starting at position 19. Expected ?, ', 0-9, * 

[statistics] disconnected

Job calendar_API_Test ended at 08:56 31/05/2023. [Exit code = 0]

but i am well connected using post man, when i do postman it give me apt data like this,

{

    

"meta"

: {

        

"code"

200

    },

    

"response"

: {

        

"holidays"

: [

            {

                

"name"

"New Year's Day"

,

                

"description"

"New Year’s Day is the first day of the year, or January 1, in the Gregorian calendar."

,

                

"country"

: {

                    

"id"

"bd"

,

                    

"name"

"Bangladesh"

                },

                

"date"

: {

                    

"iso"

"2005-01-01"

,

                    

"datetime"

: {

                        

"year"

2005

,

                        

"month"

1

,

                        

"day"

1

                    }

                },

                

"type"

: [

                    

"Common local holiday"

                ],

if you need any help please do not hesitate , i really need to take data using api and convert to json then export to data base. this is my goal.

please help me to achieve

thanks

Labels (4)
19 Replies
Anonymous
Not applicable

Hi

Can you output the response data on the console to see what data it returned?

tRestClient--main--tLogRow

 

Regards

Shong

 

modara
Creator
Creator
Author

Hi Shong,

Thnaks for your reply, here is what i get,

 

0695b00000htMacAAE.png 

i want to get calendar value via api then change to json and insert to database

 

thanks

Anonymous
Not applicable

Can you copy and paste the output here? I will try to reproduce the issue.

 

modara
Creator
Creator
Author

Starting job calendar_API_Test at 16:58 31/05/2023.

[statistics] connecting to socket on port 3335

[statistics] connected

200|<?xml version="1.0" encoding="UTF-8"?>

<root><meta><code>200</code></meta><response><holidays><name>New Year's Day</name><description>New Year’s Day is the first day of the year, or January 1, in the Gregorian calendar.</description><country><id>bd</id><name>Bangladesh</name></country><date><iso>2005-01-01</iso><datetime><year>2005</year><month>1</month><day>1</day></datetime></date><type>Common local holiday</type><primary_type>Optional Holiday</primary_type><canonical_url>https://calendarific.com/holiday/bangladesh/new-year-day</canonical_url><urlid>bangladesh/new-year-day</urlid><locations>All</locations><states>All</states></holidays><holidays><name>Bangabandhu Homecoming Day</name><description>Bangabandhu Homecoming Day is a observance in Bangladesh</description><country><id>bd</id><name>Bangladesh</name></country><date><iso>2005-01-10</iso><datetime><year>2005</year><month>1</month><day>10</day></datetime></date><type>Common local holiday</type><primary_type>Observance</primary_type><canonical_url>https://calendarific.com/holiday/bangladesh/bangabandhu-homecoming-day</canonical_url><urlid>bangladesh/bangabandhu-homecoming-day</urlid><locations>All</locations><states>All</states></holidays><holidays><name>Eid al-Adha</name><description>Eid al-Adha (Id ul-Adha) is an Islamic festival falling on the 10th

[statistics] disconnected

 

 

here it outout pertial sample. as its a long words to exceed to paste here. i give you few

modara
Creator
Creator
Author

Hi Shong,

 

this is the output from postman,

 

 

 

{

  "meta": {

    "code": 200

  },

  "response": {

    "holidays": [

      {

        "name": "New Year's Day",

        "description": "New Year’s Day is the first day of the year, or January 1, in the Gregorian calendar.",

        "country": {

          "id": "bd",

          "name": "Bangladesh"

        },

        "date": {

          "iso": "2023-01-01",

          "datetime": {

            "year": 2023,

            "month": 1,

            "day": 1

          }

        },

        "type": [

          "Common local holiday"

        ],

        "primary_type": "Optional Holiday",

        "canonical_url": "https://calendarific.com/holiday/bangladesh/new-year-day",

        "urlid": "bangladesh/new-year-day",

        "locations": "All",

        "states": "All"

      },

      {

        "name": "Bangabandhu Homecoming Day",

        "description": "Bangabandhu Homecoming Day is a observance in Bangladesh",

        "country": {

          "id": "bd",

          "name": "Bangladesh"

        },

        "date": {

          "iso": "2023-01-10",

          "datetime": {

            "year": 2023,

            "month": 1,

            "day": 10

          }

        },

        "type": [

          "Common local holiday"

        ],

        "primary_type": "Observance",

        "canonical_url": "https://calendarific.com/holiday/bangladesh/bangabandhu-homecoming-day",

        "urlid": "bangladesh/bangabandhu-homecoming-day",

        "locations": "All",

        "states": "All"

      }

    ]

  }

}

anselmopeixoto
Partner - Creator III
Partner - Creator III

Hi @Not defined Not defined​ 

 

tRESTClient component by default converts the response to a DOM XML Document. So if you use the "body" column from the response schema, you could extract the elements from the response using a tXMLMap component, for example.

 

You could change this behavior by unchecking the option "Convert Response to DOM Document" on its Advanced settings.

 

Then you should be able to use tExtractJSONFields component, but I believe you should also change the "JSON field" to use the "string" column coming from tRESTClient response schema.

 

I hope this helps.

Best regards,

Anselmo

Anonymous
Not applicable

Hi @Not defined Not defined​ 

As anselmopeixoto suggested, use tXMLMap to extract data from the returned Document, or you can use tRest or tHttpRequest to call the API, these two components returns a string response.

 

Regards

Shong

modara
Creator
Creator
Author

Hi shong,

 

so please make me clear, should i use

tRest or tHttPRequest >>>>> tXMLMAP >>>>>tmysqlinput (Convert Response to DOM Document" on its Advanced settings.)

or

tXMLMap  >>> tExtractJSONFields 

 

I am really clear to make the diagram. please help me

 

as said earlier just want to convert API data to JSON then to MYSQL

 

thanks

Anonymous
Not applicable

tRestClient--main--tXMLMAP-->tMysqlOutput

or

if the returned string is XML format, use

tRest (or tHttpRequest)--main--tExtactXMLFields--tMysqlOutput

 

if the returned string is JSON format, use

tRest (or tHttpRequest)--main--tExtactJSONFields--tMysqlOutput

 

From your screenshot, i see it is XML format.

0695b00000htULzAAM.png