HUBDB foreign ID insertion via API doesn't work

I’m trying to upload a row to my HubDB table using the following payload. It inserts everything correctly except for my foreign id column. This is the payload:

{
	"values": {
		"filename": "aPDFFile",
		"file_date": 1687392000000,
		"file_url": "https://website.com/aPDF.pdf",
		"parent_row_id": [
			{
				"id": 1234567890,
				"type": "foreignid"
			}
		]
	}
}

I’ve tried inserting the ID as a string, using different inverted commas, as a Select option too given that’s what it looks like on the web interface - nothing works. The foreign ID exists and I have published the parent table but still to no avail.

If I look at the response from the API it looks formatted incorrectly with extra commas (see line parent_row_id below):

{
	"id": "987654321",
	"createdAt": "2023-07-07T12:49:47.977Z",
	"updatedAt": "2023-07-07T12:49:47.977Z",
	"publishedAt": null,
	"values": {
		"filename": "aPDFFile",
		"file_url": "https://website.com/aPDF.pdf",
		"parent_row_id": ",1234567890,",
		"file_date": 1687392000000
	},
	"path": null,
	"name": null,
	"childTableId": "0",
	"isSoftEditable": false
}

Any help greatly appreciated

Hey @skylightipv , glad to take a look. Can you share a link to the HubDB table you’re trying to update?

Hi Carson, I’m afraid I won’t be permitted to do that though I can give you the schema below. It’s very basic. Essentially I use the Index table to power drill-down tabs on a web page by Category, Year and Month. It’s a one-to-many relationship between Index and Item tables. Any help greatly appreciated:

CategoryIndexTable

ID, Category [Single-Choice Option], Year [Long], Month [Long]

CategoryItemTable

ID, CategoryIndexID [FK to CategoryIndexTable.ID], ItemDate [Date], ItemName [String], ItemURL [URL]

Thanks @skylightipv. Yesterday I was able to replicate the response formatting issue in my account and have flagged that to the HubDB team. I’ll update you here as the team investigates the formatting.

To clarify the issue, is the response formatting the core problem? Or are the foreign IDs not actually saved in the HubDB table? If you check the row in the HubDB table UI or fetch the row with a GET request to /cms/v3/hubdb/tables/{tableIdOrName}/rows/{rowId} (doc), are the foreign IDs present?

Based on my tests and your payload (assuming valid IDs), the rows should be stored in the row correctly and this is just a response formatting issue. (The foreign ID values in the payload can be strings or numbers).

Thank you. The issue is that the FK does not get inserted into the table for me

Thanks, @skylightipv. The values not being updated in the table appears to be dependent on your exact request and HubDB table. The team has written a fix for the foreign ID formatting issue (this should be live early next week), but to help us investigate the IDs not being added to your table, can you file a support ticket with the details of the exact request you’re making (exact request URL, method, and payload) along with a link to the table you are trying to update? That will allow us to investigate more closely. You can also provide a link to this community post so the team has the context of the ticket.

Thanks I’ve raised a ticket. The JSON response actually looks successful but the value is not present in the browser