Unable to add list to the record

        cout<<endl<<"Enter the name: ";
        string pk;

        as_key_init(&key, "test", "vishal_set", pk.c_str());

        cout<<endl<<"Enter the age: ";
        int age;

        as_record_set_int64(&rec, "age", age);

        cout<<endl<<"Enter the contact no: ";
        string contact_no;
        as_record_set_str(&rec, "contact_no", contact_no.c_str());

        as_arraylist list;

        as_arraylist_append_str (&list, "playing football");
        as_arraylist_append_str (&list, "playing cricket");
        as_arraylist_append_str(&list,"playing badminton");

        if(!(as_record_set_list(&rec, "hobbies", (as_list *)&list)))
        if (aerospike_key_put(&as, &err,NULL, &key, &rec) != AEROSPIKE_OK)
                printf("error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);

age and contact_no are getting added to the record(I can see them in aql), however, ‘as_record_set_list(&rec, “hobbies”, (as_list *)&list)’ is returning false. Please help.


Fortunately, I’ve found the reason why my list was not getting added to the record myself. It turned out to be really silly mistake.

The reason was that I had done a mistake in initializing as_record. Since I was adding 3 bins to the record therefore, I should have initialised it as as_record_init(&rec, 3);.