# AJAX GET example

**URL:** <https://community.hubspot.com/t/ajax-get-example/21715>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [June 15, 2020, 3:40pm UTC](https://community.hubspot.com/t/ajax-get-example/21715 "2020-06-15T15:40:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![missa815](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/missa815/32/68653_2.png) [@missa815](https://community.hubspot.com/u/missa815)\
**Post date:** [June 15, 2020, 3:40pm UTC](https://community.hubspot.com/t/ajax-get-example/21715/1 "2020-06-15T15:40:17Z")

</div>

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:

- [https://developers.hubspot.com/docs/methods/hubdb/hubdb\_overview](https://developers.hubspot.com/docs/methods/hubdb/hubdb_overview)
- [https://developers.hubspot.com/docs/methods/hubdb/v2/get\_table\_rows](https://developers.hubspot.com/docs/methods/hubdb/v2/get_table_rows)

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

- [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/faq/do-hubspot-apis-support-ajax-request)

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

```auto
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

```

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

```

---

<div class="post-metadata">

**Author:** ![missa815](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/missa815/32/68653_2.png) [@missa815](https://community.hubspot.com/u/missa815)\
**Post date:** [June 15, 2020, 7:42pm UTC](https://community.hubspot.com/t/ajax-get-example/21715/2 "2020-06-15T19:42:36Z")

</div>

Nevermind, I didn’t pay close attention to the documentation [here](https://developers.hubspot.com/docs/methods/hubdb/v2/get_table_rows):

| 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

```auto
 $.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](https://app.hubspot.com/hubdb/ **YourPortalID** /table/**YourTableID)\*\*
