cancel
Showing results for 
Search instead for 
Did you mean: 

POST request for an entity

0 Kudos
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.

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
Active Contributor

First of all I would suggest that you check out the CAP Naming Conventions. Then check out the example in the HTTP Client script: tests/catalog.http#L35. I think that the issue is with the QUESTION attribute. It should be QUESTION_Q_ID. But please check out also the Common Types & Aspects as they will help you to get your data model more elegant and short.

Answers (0)