Indicia-Team / warehouse

GNU General Public License v3.0
5 stars 3 forks source link

Unify REST API GET and POST/PUT values #520

Open kazlauskis opened 5 months ago

kazlauskis commented 5 months ago

The Warehouse REST API allows to create, fetch and update existing models, but the interface is slightly different. I want to be able to POST a new model (say a sample), then GET the values from the warehouse, and PUT updated values. The main issue is that term list values return labels rather than warehouse IDs, so I cannot PUT the values I received from the GET request.

POST

{
  "values": {
    "date": "19/06/2024",
    "entered_sref_system": 4326,
    "entered_sref": "54.8978567, 23.8933197",
    "smpAttr:922": 2398
  }
}

GET

{
  "values": {
    "date": "19/06/2024",
    "entered_sref_system": 4326,
    "entered_sref": "54.8978567, 23.8933197",
     "smpAttr:922": "iOS",
  }
}

PUT

{
  "values": {
    "date": "19/06/2024",
    "entered_sref_system": 4326,
    "entered_sref": "54.8978567, 23.8933197",
     "smpAttr:922": "iOS", <--- ERROR:  "Invalid value iOS for attribute Data Source"
  }
}