Search code examples
javaspring-bootjpaairtable

Updating a linked column gives an error in airtable


I have a table called event. event table has a linked column called attendees which is linked to the attendee table. that means attendees column contains a list of ids of attendee table. You can see this in the image. enter image description here

I am trying to update that column using following code which used spring boot jpa. The userId I used here is an existing Id in the attendee table.

  public Event registerUser(String eventId, String userId) {
        Event event = (Event) this.getEventById(eventId).get();
        List<String> list = event.getAttendees();
        list.add(userId);
        event.setAttendees(list);
        return eventRepository.update(event);
    }



 public Event update(Event event) {
        return this.table.update(event);
    }

But it gives following error

.AirtableException: Value is not an array of record IDs. (INVALID_VALUE_FOR_COLUMN) [Http code 422]

Please help.


Solution

  • I found that you cannot have so many columns from linked table inside your original table when you are going to update. for example if we have attendees_name, attendees_age like columns from attendee table other than the attendees column inside the event table you cannot update the linked columns of attendee_name and attendee_age. You can only set values to attendee column. therefore what you can do is you can remove the attributes of attendeeName and attendeeAge from your entity class. I'll put here the entity class I used while using spring boot

     @Data
        @EqualsAndHashCode
        @ToString
        public class Event {
        
            private String id;
            private String activity;
            private String type;
            private String description;
            private String image;
            private String price;
            private Date start;
            private Date end;
            private List<String> attendees;
            //private List<String> attendeeNames; 
            //private List<String> attendeeAges;
            private String level;
            private List<String> days;
            private String officeRndId;
            private int seatCount;
          
        }