Skip to Content
0

How to handle Olingo v2 single call that would overwrite complete table contents?

Mar 20 at 11:05 AM

58

avatar image

Customer requirement is to have the document-like behavior for the list of the items. It means that the user can play (modify, delete or insert entry) with the list and only after pressing “Save” the list is stored in the backend. All changes before pressing save are only stored in the local model.

Here is how the structure of the tables in the backend could look like:

The assumption is that the Model table contents should be kept in sync with what user has in frontend by single odata call at “Save” button press. The odata call would overwrite the complete set of entries for each BrandID in Model table. For example in order to make the change that would look in the frontend like this:

Frontend would send the following call:

PUT /cars-sample/Service.svc/Brands('Audi')
HTTP/1.1Host:
localhost:8081Content-Type:
application/json
{  
   "Model" :
   [  
      {
           "ModelName": ""
      },
      {    
           "ModelName": "X3"  
      },  
      {    
           "ModelName": "X6"
      }  
   ]
}

The question is: how to set up this call in olingo v2?

1.png (5.4 kB)
2.png (6.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Ralf Handl
Mar 20 at 11:17 AM
0

OData V2 does not support replacing of arrays/lists with PUT. Instead you have to send a batch request containing a change set with DELETE requests for list items that have to be removed, PUT/PATCH requests for list items that have to be changed, and POST requests for list items that have to be created.

"Deep update" has only recently been introduced with OData V4.01.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you for your help

0