如何在 SAP Hybrid Application Toolkit 中将 Content-ID header 设置为正确的请求?
How to set Content-ID header to the correct request in SAP Hybrid Application Toolkit?
我正在尝试为创建两个实体生成批处理请求:一个 Parent 实体和一个属于 parent 的 Child 实体。对于它们之间的联动我想使用OData Content-ID header。我通过这个生成请求:
this.model.create("/ParentSet", {
Id: "000777000",
Store: "16"
}, {
error: function (errormessage) {
alert("create error" + JSON.stringify(errormessage));
},
headers: {
"content-ID": 1
}
});
this.model.create("//ToChild", {
Id: "131313",
Area: ""
}, {
error: function (errormessage) {
alert("create error" + JSON.stringify(errormessage));
}
});
当从 Web sapui5 应用程序执行时,代码会创建正确的请求负载:
--batch_a8d1-2414-ee3e
content-type: multipart/mixed; boundary=changeset_0f62-99e1-b9a4
--changeset_0f62-99e1-b9a4
content-type: application/http
content-transfer-encoding: binary
POST ParentSet HTTP/1.1
content-ID: 1
sap-contextid-accept: header
Accept: application/json
Accept-Language: en-GB
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
x-csrf-token: UrrKfxCwzgpBlY8GVgtdWg==
Content-Type: application/json
Content-Length: 31
{"Id":"000777000","Store":"16"}
--changeset_0f62-99e1-b9a4
content-type: application/http
content-transfer-encoding: binary
POST /ToChild HTTP/1.1
sap-contextid-accept: header
Accept: application/json
Accept-Language: en-GB
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
x-csrf-token: UrrKfxCwzgpBlY8GVgtdWg==
Content-Type: application/json
Content-Length: 48
{"Id":"131313","Area":""}
--changeset_0f62-99e1-b9a4--
--batch_a8d1-2414-ee3e
content-type: application/http
content-transfer-encoding: binary
GET ParentSet/$count HTTP/1.1
sap-cancel-on-close: true
sap-contextid-accept: header
Accept: text/plain, */*;q=0.5
Accept-Language: en-GB
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
x-csrf-token: UrrKfxCwzgpBlY8GVgtdWg==
--batch_a8d1-2414-ee3e
content-type: application/http
content-transfer-encoding: binary
GET ParentSet?$skip=0&$top=100 HTTP/1.1
sap-cancel-on-close: true
sap-contextid-accept: header
Accept: application/json
Accept-Language: en-GB
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
x-csrf-token: UrrKfxCwzgpBlY8GVgtdWg==
--batch_a8d1-2414-ee3e--
但是,当从基于 Cordova 的 SAP HAT 应用程序执行时,content-id header 被放置到更改集而不是像这样的 Parent 实体:
--batch_709b8b9352ac4342a0efb1e012d_1
content-type: multipart/mixed; boundary=changeset_709b8b9352ac4342a0efb1e012d_2
--changeset_709b8b9352ac4342a0efb1e012d_2
content-type: application/http
content-transfer-encoding: binary
content-id: 1
POST ParentSet HTTP/1.1
Content-Type: application/json
Accept: application/json;q=1, application/atom+xml;q=0.5
accept-language: en-US
sap-contextid-accept: header
{"Id":"000777000","Store":"16"}
--changeset_709b8b9352ac4342a0efb1e012d_2
content-type: application/http
content-transfer-encoding: binary
POST /ToChild HTTP/1.1
Content-Type: application/json
Accept: application/json;q=1, application/atom+xml;q=0.5
accept-language: en-US
sap-contextid-accept: header
{"Id":"131313","Area":""}
--changeset_709b8b9352ac4342a0efb1e012d_2--
--batch_709b8b9352ac4342a0efb1e012d_1--
有没有人对如何解决这个问题有任何建议,以便 content-id header 正确地附加到 Parent 实体而不是更改集?
你尝试了吗
var oModel = new sap.ui.model.json.JSONModel(your header data here);
this.getView().setModel(oModel,"HeaderDataModel");
// and then you can use header data anywhere in the view using "HeaderDataModel"
<button enabled ="{HeaderDataModel>/HeaderAttr2}">
来自这里:
https://answers.sap.com/questions/31885/ui5-path-to-parent-property.html
问题已通过更改 SAP CP 移动服务中的离线配置解决。在 Mobile Application > Native/Hybrid > Info > Assigned Features > Offline > Configuration 下,您需要单击编辑按钮。在 popup-menu
如果是“Mime”,Content ID Header Location 必须设置为“Operation”。
screenshot of the configuration menu
screenshot of the configuration menu
我正在尝试为创建两个实体生成批处理请求:一个 Parent 实体和一个属于 parent 的 Child 实体。对于它们之间的联动我想使用OData Content-ID header。我通过这个生成请求:
this.model.create("/ParentSet", {
Id: "000777000",
Store: "16"
}, {
error: function (errormessage) {
alert("create error" + JSON.stringify(errormessage));
},
headers: {
"content-ID": 1
}
});
this.model.create("//ToChild", {
Id: "131313",
Area: ""
}, {
error: function (errormessage) {
alert("create error" + JSON.stringify(errormessage));
}
});
当从 Web sapui5 应用程序执行时,代码会创建正确的请求负载:
--batch_a8d1-2414-ee3e
content-type: multipart/mixed; boundary=changeset_0f62-99e1-b9a4
--changeset_0f62-99e1-b9a4
content-type: application/http
content-transfer-encoding: binary
POST ParentSet HTTP/1.1
content-ID: 1
sap-contextid-accept: header
Accept: application/json
Accept-Language: en-GB
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
x-csrf-token: UrrKfxCwzgpBlY8GVgtdWg==
Content-Type: application/json
Content-Length: 31
{"Id":"000777000","Store":"16"}
--changeset_0f62-99e1-b9a4
content-type: application/http
content-transfer-encoding: binary
POST /ToChild HTTP/1.1
sap-contextid-accept: header
Accept: application/json
Accept-Language: en-GB
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
x-csrf-token: UrrKfxCwzgpBlY8GVgtdWg==
Content-Type: application/json
Content-Length: 48
{"Id":"131313","Area":""}
--changeset_0f62-99e1-b9a4--
--batch_a8d1-2414-ee3e
content-type: application/http
content-transfer-encoding: binary
GET ParentSet/$count HTTP/1.1
sap-cancel-on-close: true
sap-contextid-accept: header
Accept: text/plain, */*;q=0.5
Accept-Language: en-GB
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
x-csrf-token: UrrKfxCwzgpBlY8GVgtdWg==
--batch_a8d1-2414-ee3e
content-type: application/http
content-transfer-encoding: binary
GET ParentSet?$skip=0&$top=100 HTTP/1.1
sap-cancel-on-close: true
sap-contextid-accept: header
Accept: application/json
Accept-Language: en-GB
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
x-csrf-token: UrrKfxCwzgpBlY8GVgtdWg==
--batch_a8d1-2414-ee3e--
但是,当从基于 Cordova 的 SAP HAT 应用程序执行时,content-id header 被放置到更改集而不是像这样的 Parent 实体:
--batch_709b8b9352ac4342a0efb1e012d_1
content-type: multipart/mixed; boundary=changeset_709b8b9352ac4342a0efb1e012d_2
--changeset_709b8b9352ac4342a0efb1e012d_2
content-type: application/http
content-transfer-encoding: binary
content-id: 1
POST ParentSet HTTP/1.1
Content-Type: application/json
Accept: application/json;q=1, application/atom+xml;q=0.5
accept-language: en-US
sap-contextid-accept: header
{"Id":"000777000","Store":"16"}
--changeset_709b8b9352ac4342a0efb1e012d_2
content-type: application/http
content-transfer-encoding: binary
POST /ToChild HTTP/1.1
Content-Type: application/json
Accept: application/json;q=1, application/atom+xml;q=0.5
accept-language: en-US
sap-contextid-accept: header
{"Id":"131313","Area":""}
--changeset_709b8b9352ac4342a0efb1e012d_2--
--batch_709b8b9352ac4342a0efb1e012d_1--
有没有人对如何解决这个问题有任何建议,以便 content-id header 正确地附加到 Parent 实体而不是更改集?
你尝试了吗
var oModel = new sap.ui.model.json.JSONModel(your header data here);
this.getView().setModel(oModel,"HeaderDataModel");
// and then you can use header data anywhere in the view using "HeaderDataModel"
<button enabled ="{HeaderDataModel>/HeaderAttr2}">
来自这里: https://answers.sap.com/questions/31885/ui5-path-to-parent-property.html
问题已通过更改 SAP CP 移动服务中的离线配置解决。在 Mobile Application > Native/Hybrid > Info > Assigned Features > Offline > Configuration 下,您需要单击编辑按钮。在 popup-menu 如果是“Mime”,Content ID Header Location 必须设置为“Operation”。
screenshot of the configuration menu
screenshot of the configuration menu