How use PostAsync? FK / MasterDetail

Insert record Master/Detail o FK with PostAsync

XDOrderMaster.Active := True;
XDOrderMaster.Append;

(more fields)

XDOrderMaster.Post;

jsonString := XDOrderMaster.CurrentData;

jsonString := {this variable contain my json string) --> I get from a Dataset
but have some FK

How build
"Store@xdata.ref": "Store(1)",

jsonObject := TJSObject.new;
jsonObject := TJSJSON.parseObject(jsonString) as TJSObject;

await(WMLabStore.XDataLabEngine.OpenAsync);
Response3 := await(WMLabStore.XDWebClient.PostAsync('OrderMaster', jsonObject ));

Sorry, but your question is really confusing. I cannot understand what you want to achieve. Do you have a sample, or can you explain in more details what your code does (or should do), what is "Store", what is "OrderMaster",, what is "XDataLabEngine", what error or wrong behavior you get, etc.)?

Dear Wagner

Sorry my confusion question...
I prepare a test case sample with a video.
TextCase.zip (121.3 KB)

The test case contain a XData Server and Web Client.
Video explain https://youtu.be/SqAK2W9dQq8

Thank you for the project and video. The server returned the error:

Expected BeginArray but was Null at path $.Items

So to solve it you should initialize the Items field with an empty array:

  XDOrderMasterItems.Value := TJSArray.new;
1 Like

Work perfectly!!!
Thank you.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.