APIs & Integrations

sjay
Member | Diamond Partner
Member | Diamond Partner

Can I integrate the 3rd party API in our HubSpot account to pull the Data?

SOLVE

Hi Team,

 

I Have a 3rd party API from myNewsDesk. Below is the URL which is in XML format.

 

Now I wanted to Integrate it into our HubSpot account and I want to pull the results in our HubSpot Webpage.

 

Is that possible? 

 

https://www.mynewsdesk.com/services/pressroom/list/zer0r_Gd0PCxImHUtPl4rA/

 

Thanks,

Sanjay

0 Upvotes
1 Accepted solution
piersg
Solution
Key Advisor

Can I integrate the 3rd party API in our HubSpot account to pull the Data?

SOLVE

Hi @sjay (thanks @dennisedson). You could use JS fetch, like this:

fetch('https://www.mynewsdesk.com/services/pressroom/list/zer0r_Gd0PCxImHUtPl4rA/')
.then(response=>response.text())
.then(data=>{
    const parser = new DOMParser();
    const xmlDOM = parser.parseFromString(data,"text/xml");
    let items = xmlDOM.getElementsByTagName('item');
    for (i = 0, len = items.length; i < len; i++) {
        let item = items[i];
        console.log(item);
    }
})
.catch(err=>console.log(err))

View solution in original post

4 Replies 4
sjay
Member | Diamond Partner
Member | Diamond Partner

Can I integrate the 3rd party API in our HubSpot account to pull the Data?

SOLVE

Hi, @piersg and @dennisedson,

 

Thanks a lot. Below is the code that is working.


My design is in the form of Listing and detail pages.

For Example https://www.columbusglobal.com/sv/nyheter --> Listing Page

So now I can create a listing page like the above page with the API content. And I will pass the query string value while we click on each item to redirect to the Detail Page.

Here we have two challenges.

  1. Is it possible to create User-Friendly Urls/ SEO URLs for each detail page instead of query string?
  2. Is it possible to add custom OG/Meta Title and OG/Meta Description in each detail page with these Javascript Variables?

    <p id="body_text">
    </p>
    <script>
    fetch('https://www.mynewsdesk.com/services/pressroom/list/zer0r_Gd0PCxImHUtPl4rA/')
    .then(response=>response.text())
    .then(data=>{
    const parser = new DOMParser();
    const xmlDOM = parser.parseFromString(data,"text/xml");
    let items = xmlDOM.getElementsByTagName('item');

    for (i = 0, len = items.length; i < len; i++) {
    debugger;
    let item = items[i];
    var News_body= item.getElementsByTagName("body")[0].childNodes[0].nodeValue;
    console.log(item);

    $( "#body_text" ).append( News_body );

    }
    })
    .catch(err=>console.log(err))

    </script>

0 Upvotes
piersg
Solution
Key Advisor

Can I integrate the 3rd party API in our HubSpot account to pull the Data?

SOLVE

Hi @sjay (thanks @dennisedson). You could use JS fetch, like this:

fetch('https://www.mynewsdesk.com/services/pressroom/list/zer0r_Gd0PCxImHUtPl4rA/')
.then(response=>response.text())
.then(data=>{
    const parser = new DOMParser();
    const xmlDOM = parser.parseFromString(data,"text/xml");
    let items = xmlDOM.getElementsByTagName('item');
    for (i = 0, len = items.length; i < len; i++) {
        let item = items[i];
        console.log(item);
    }
})
.catch(err=>console.log(err))
dennisedson
HubSpot Product Team
HubSpot Product Team

Can I integrate the 3rd party API in our HubSpot account to pull the Data?

SOLVE

@piersg , I thought you were more of an fetch async/await type of guy.  I don't judge. 🙃

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Can I integrate the 3rd party API in our HubSpot account to pull the Data?

SOLVE

@piersg ,

Any thoughts for @sjay ?

0 Upvotes