We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Jun 15, 2020 11:40 AM - edited Jun 15, 2020 12:01 PM
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'); } });
Solved! Go to Solution.
Jun 15, 2020 3:42 PM
Nevermind, I didn't pay close attention to the documentation here:
Hub/account ID | portalId={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
Jun 15, 2020 3:42 PM
Nevermind, I didn't pay close attention to the documentation here:
Hub/account ID | portalId={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