APIs & Integrations

kevinallauca
Member

400 Bad request on hubDb table

Hi everyone, I am trying to show a table with information from a Hubdb. I am using this Bootstrap-table example: https://live.bootstrap-table.com/example/options/table-ajax.html

 

I have modified it like this:

<table
id="table"
data-toggle="table"
data-height="460"
data-ajax="ajaxRequest"
data-search="true"
data-content-type="application/json"
data-data-type="text">
<thead>
<tr>
<th data-field="id">ID</th>
<th data-field="sierra">Sierra</th>
<th data-field="costa">Costa</th>
</tr>
</thead>
</table>

<script>
// your custom ajax request here
function ajaxRequest(params) {
var url = 'https://api.hubapi.com/hubdb/api/v2/tables/5251215/rows?portalId=3395898'
$.get(url + '?' + $.param(params.data)).then(function (res) {
params.success(res)
})
}
</script>

It loads like this:

Captura de Pantalla 2021-07-22 a la(s) 11.51.57.png

 and in console shows the error 400:

Captura de Pantalla 2021-07-22 a la(s) 11.52.19.png

I have tried to get the information I needed from a JSON hosted inside the same folder of the landing page I am building but I am getting the CORS error from hubspot, that's why I tried this other way.

 

BTW I am not a professional coder or IT enginner all of this I have learned by myself, so excuse me if the issue is bit obvius 😅

0 Upvotes
1 Reply 1
webdew
Guide | Diamond Partner
Guide | Diamond Partner

400 Bad request on hubDb table

Hi @kevinallauca ,

Hope this will work :
Please use below documentation for fetch data.
https://legacydocs.hubspot.com/docs/methods/hubdb/v2/get_table_rows

Screen shot :
https://prnt.sc/1eoyawo

This example filters by a column and order by
and sorts the rows by a date field named 'a_date', with the latest dates first:
https://api.hubapi.com/hubdb/api/v2/tables/5251215/rows?portalId=3395898&<propertyKey>__eq=10&orderB...

Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 

0 Upvotes