Field API: Updating a Equipment Creates a Duplicated Record

Q. I’m trying to update an existing equipment record. By calling /api/equipment, however, I end up creating a new record with the same values.  I used /api/get_equipment to get an equipment record, and using /api/equipment to update. What do I need to do to update an existing record?

A. Please check your JSON string representing a record and make sure that you are using “id” and not “equipment_id”. For example, if your equipment ID in JSON data looks like this:

[{“equipment_id“:”a9df893e-d9b9-4098-b434-e7d2be62d0a8”, …

then, you will need to modify it to:

[{“id“:”a9df893e-d9b9-4098-b434-e7d2be62d0a8”, …

/api/equipment takes “id” as a name of parameter. If you use /api/get_equipment, it returns a record with “equipment_id”. If you use “equipment_id”, it is considered as no “id” is specified and the system creates a new record with the given data.

The documentation clearly says “id”. But this seems to be something easily overlooked, and people occasionally stumble…

16fieldapiequipmentdoc

Mikako

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s