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

post array using ODataV4 / V2

torincit0
Discoverer
0 Kudos
141

Hello Experts, 

 

I have this JSON Post in Odata 

{
"brand" : "ShopRite",
"fundingType" : 10,
"offerCode" : "25041101",
"gs1CoPrefix" : "",
"familyCode" : "0",
"offerSeries" : "1",
"manufacturerCodes" : [ "text", "text2" ],
"taxesReclaimable" : false,
"isTender" : false
}

manufacturerCodes is the array expected by the client.

How can we configure and implement a system to handle arrays in SEGW for OData? I know there are complex types or Collection types in V4, but those require a property (the sub-object has a field label like)  

"manufacturerCodes" : [  code: "text",

                                        code "text2" ]

or 

"manufacturerCodes" : [ { code: "text", }

                                       { code: "text2"  }

                                  ],

Any idea? Is there any standard approach to post a field with an array to SAP OData?

If we post, I'm having this error: "error while parsing an XML stream". Already tried using a collection or complex type.

 

Please
Thanks a lot for your time to help

 

View Entire Topic
M-K
Active Participant
0 Kudos

Hello,

if you can use oData V4, you can define a property as collection of Edm.String (Have a look at the answer there: https://community.sap.com/t5/technology-q-a/post-array-in-single-field-via-odata-service/qaq-p/12485...).

I don't think it is possible to do it with oData V2 and SEGW in a "standard way". If you can change the incoming JSON format, you can stringify the array (or just use a comma separated string) and parse it on the ABAP side as workaround, or use an association to a new entity for "manufacturerCodes" (with the downside of needing a "code" property there, too).

torincit0
Discoverer
0 Kudos
Thanks for your time. Just to mention in OdataV4 I don't any option to define the property as collection as the other blog mention.
torincit0
Discoverer
0 Kudos
The collection is only available for navigation properties.