APIs & Integrations

missa815
Member

AJAX GET example

SOLVE

Can someone please provide an example of an AJAX GET request using a HubDB?
Please let me know if it is possible to access the a HubDB table via AJAX or if I need to upload my table on an external SQL host.


I am referencing:


This link says that most GET requests work with published HubDB tables (second bullet on the page):

 

I'm receiving the following console error when using the code found at the bottom:

 

jquery-3.4.1.min.js:formatted:3879 GET https://{{my_website}}/hubdb/api/v2/tables/:{{HubDB_TableID}}/rows 404
send @ jquery-3.4.1.min.js:formatted:2
ajax @ jquery-3.4.1.min.js:formatted:2
(anonymous) @ module_30654825430_RFQ_DropDownFilterTable_copy.min.js:1
dispatch @ jquery-3.4.1.min.js:formatted:2
v.handle @ jquery-3.4.1.min.js:formatted:2
ListPicker._handleMouseUp
DevTools failed to load SourceMap: Could not parse content for https://app.hubspot.com/content/editor/prefetcher.js.map: Unexpected token ! in JSON at position 0

 

 

    $.ajax({
      url: "https://api.hubapi.com/hubdb/api/v2/tables/:{{HubDB_TableID}}/rows",
      success: function (xml) {
      console.log('success');
      }
    });

 

0 Upvotes
1 Accepted solution
missa815
Solution
Member

AJAX GET example

SOLVE

Nevermind, I didn't pay close attention to the documentation here:

 

Hub/account IDportalId={Hub ID}
Used in the request URL
The Hub ID that the table belongs to.
Table Id{tableId}
Used in the request URL
The ID of the table that you're looking for.

 

here's my working AJAX call

 

    $.ajax({
      url: "https://api.hubapi.com/hubdb/api/v2/tables/{{HubDB_TableID}}/rows?portalId={{HubDB_ID}},
      success: function (xml) {
      console.log('success');
      }
    });

 

I basically missed the part where it needed an ID for

portalID=

which is the first ID number in the HubDB table URL:

 

When you are accessing your table in HubDB, the URL will show:

 

 https://app.hubspot.com/hubdb/YourPortalID/table/YourTableID

View solution in original post

1 Reply 1
missa815
Solution
Member

AJAX GET example

SOLVE

Nevermind, I didn't pay close attention to the documentation here:

 

Hub/account IDportalId={Hub ID}
Used in the request URL
The Hub ID that the table belongs to.
Table Id{tableId}
Used in the request URL
The ID of the table that you're looking for.

 

here's my working AJAX call

 

    $.ajax({
      url: "https://api.hubapi.com/hubdb/api/v2/tables/{{HubDB_TableID}}/rows?portalId={{HubDB_ID}},
      success: function (xml) {
      console.log('success');
      }
    });

 

I basically missed the part where it needed an ID for

portalID=

which is the first ID number in the HubDB table URL:

 

When you are accessing your table in HubDB, the URL will show:

 

 https://app.hubspot.com/hubdb/YourPortalID/table/YourTableID