cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

UnManaged RAP CDS Odata V4 - JSON array POST method

enry79
Explorer
0 Likes
996

Hi,

  I have an Unmanaged RAP "Behavior Definition" public on Odatav4 Service Binding:

unmanaged implementation in class <my_class> unique;
strict ( 2 );
define behavior for <my_cds>
lock master
authorization master ( instance )
{
create;
}

In Create Method:

LOOP AT entities ASSIGNING FIELD-SYMBOL(<fs>).
* my checks
ENDLOOP.

In this example My_Cds have only 2 fields: test (key), description.

POSTMAN test:

When I try to send POST method with JSON Body with single entity work good:

 {
    "test""001",
     "description""Hello"
 }
When I try to send array entities like this:
[
   {
     "test""001",
     "description""Hello"
   },
   {
      "test""002",
      "description""Hello hello"
    }
]
The service response with 400 BadRequest:
 "message": {
            "lang""en",
            "value""Error while parsing an XML stream"
        }
 
I don't understand... Is JSON array correct?
On RAP Model, with unmanaged "Behavior Definition", can I send array records in Insert methods or there's a limitation of number of records?
 
Thanks

Accepted Solutions (1)

Accepted Solutions (1)

MioYasutake
SAP Champion
SAP Champion

@enry79 

The create endpoint of an OData service is intended for posting a single entity, not an array.

If you want to post multiple records in one request, use a batch request. 

An alternative is to create an action that accepts a deep parameter.

https://help.sap.com/docs/abap-cloud/abap-rap/modeling-parameters-for-non-standard-operations

 

 

enry79
Explorer
0 Likes
Thank you for answer.

Answers (0)