Skip to Content
0
Nov 02, 2020 at 12:07 PM

POST request for an entity

416 Views

entity T_QUESTION {
    key Q_ID         : UUID;
        SESSION      : String(150);
        QUESTION     : String(2000);
        USER         : String(256);
        Q_GEN_TMSTMP : Timestamp @cds.on.insert : $now;
        ANSWERS      : Composition of many T_ANSWER
                           on ANSWERS.QUESTION = $self;
}
 
entity T_ANSWER {
    key A_ID         : UUID;
        SESSION      : String(150);
        QUESTION     : Association to T_QUESTION;
        ANSWER       : String(4000);
        USER         : String(256);
        A_GEN_TMSTMP : Timestamp @cds.on.insert : $now;
}


service QA {
    entity questions as projection on rbei.T_QUESTION;

    entity answers as projection on rbei.T_ANSWER;
}


when trying to pass a POST request on answers. I'm getting an error.

axios.post('url/qa/answers',{
            "SESSION":session,
            "QUESTION": qid,
            "ANSWER":answer,
            "USER":user
        })

Error:

{"error":{"code":"null","message":"Error while deserializing payload. Value for structural type must be an object."}}

can anyone correct this and help me with the payload.

Thank you.

Pratheek.