kaoki
January 12, 2022, 11:36am
1
Hi, I`m using HubDB API .
I tried to create table which has a Foreign ID type column, and I got following error.
HTTP 400
Foreign table id must be defined: {name='text_column', label=Text Column, type=FOREIGN_ID, id=1, deleted=false, options=[], foreignTableId0, width=null}
Here is an entire request log.
curl --request POST \
--url 'https://api.hubapi.com/cms/v3/hubdb/tables?hapikey={{API_KEY}}' \
--header 'content-type: application/json' \
--data '{
"name": "test_table",
"label": "Test Table",
"useForPages": true,
"columns": [
{
"name": "text_column",
"label": "Text Column",
"id": "1",
"type": "FOREIGN_ID"
}
],
"allowChildTables": true,
"enableChildTablePages": false,
"allowPublicApiAccess": false
}'
It seems that the error occurs because I don`t specify foreign table id.
I read the API documents but I didn`t found out how to specify it.
How do I specify foreign table id?
Thank you.
@stefen , think you could assist here?
stefen
January 13, 2022, 12:51am
3
@kaoki @dennisedson the foreign id column should be an array with objects inside of it since you can have multiple IDs in that field. So, for example the log should look more like this:
curl --request POST \
--url 'https://api.hubapi.com/cms/v3/hubdb/tables?hapikey={{API_KEY}}' \
--header 'content-type: application/json' \
--data '{
"name": "test_table",
"label": "Test Table",
"useForPages": true,
"columns": [
{
"name": "text_column" [
{
"id": "1",
"type": "foreignid"
},
{
"id": "2",
"type": "foreignid"
}
]
}
],
"allowChildTables": true,
"enableChildTablePages": false,
"allowPublicApiAccess": false
}'
kaoki
January 13, 2022, 2:54am
4
@stefen @dennisedson
Thank you for the response.
But it didn`t work for me.
I found solution.
I just added “foreignTableId” property to column object, and it worked.
Here is request log
curl --request POST \
--url 'https://api.hubapi.com/cms/v3/hubdb/tables?hapikey={{API_KEY}}' \
--header 'content-type: application/json' \
--data '{
"name": "test_table",
"label": "Test Table",
"useForPages": true,
"columns": [
{
"name": "text_column",
"label": "Text Column",
"id": "1",
"type": "FOREIGN_ID",
"foreignTableId": 5316197,
"foreignColumnId": 1
}
],
"allowChildTables": true,
"enableChildTablePages": false,
"allowPublicApiAccess": false
}'