# HUBDB foreign ID insertion via API doesn't work

**URL:** <https://community.hubspot.com/t/hubdb-foreign-id-insertion-via-api-doesnt-work/84894>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [July 7, 2023, 11:31am UTC](https://community.hubspot.com/t/hubdb-foreign-id-insertion-via-api-doesnt-work/84894 "2023-07-07T11:31:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![skylightipv](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@skylightipv](https://community.hubspot.com/u/skylightipv)\
**Post date:** [July 7, 2023, 11:31am UTC](https://community.hubspot.com/t/hubdb-foreign-id-insertion-via-api-doesnt-work/84894/1 "2023-07-07T11:31:58Z")

</div>

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:

```lia-code-sample
{
	"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):

```lia-code-sample
{
	"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

---

<div class="post-metadata">

**Author:** ![cwilliford](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cwilliford/32/48852_2.png) [@cwilliford](https://community.hubspot.com/u/cwilliford)\
**Post date:** [July 20, 2023, 3:15pm UTC](https://community.hubspot.com/t/hubdb-foreign-id-insertion-via-api-doesnt-work/84894/2 "2023-07-20T15:15:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![skylightipv](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@skylightipv](https://community.hubspot.com/u/skylightipv)\
**Post date:** [July 21, 2023, 7:41am UTC](https://community.hubspot.com/t/hubdb-foreign-id-insertion-via-api-doesnt-work/84894/3 "2023-07-21T07:41:11Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![cwilliford](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cwilliford/32/48852_2.png) [@cwilliford](https://community.hubspot.com/u/cwilliford)\
**Post date:** [July 21, 2023, 4:57pm UTC](https://community.hubspot.com/t/hubdb-foreign-id-insertion-via-api-doesnt-work/84894/4 "2023-07-21T16:57:12Z")

</div>

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](https://developers.hubspot.com/docs/api/cms/hubdb)), 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).

---

<div class="post-metadata">

**Author:** ![skylightipv](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@skylightipv](https://community.hubspot.com/u/skylightipv)\
**Post date:** [July 21, 2023, 7:24pm UTC](https://community.hubspot.com/t/hubdb-foreign-id-insertion-via-api-doesnt-work/84894/5 "2023-07-21T19:24:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cwilliford](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cwilliford/32/48852_2.png) [@cwilliford](https://community.hubspot.com/u/cwilliford)\
**Post date:** [July 21, 2023, 8:30pm UTC](https://community.hubspot.com/t/hubdb-foreign-id-insertion-via-api-doesnt-work/84894/6 "2023-07-21T20:30:51Z")

</div>

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](https://knowledge.hubspot.com/account/get-help-with-hubspot) 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.

---

<div class="post-metadata">

**Author:** ![skylightipv](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@skylightipv](https://community.hubspot.com/u/skylightipv)\
**Post date:** [July 25, 2023, 10:22am UTC](https://community.hubspot.com/t/hubdb-foreign-id-insertion-via-api-doesnt-work/84894/7 "2023-07-25T10:22:39Z")

</div>

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