简体   繁体   English

如何从SAP Cloud SDK中的JavaScript的DocumentInfoRecord get()调用中获取eTag(MetaData)?

[英]How to get the eTag(MetaData) from a DocumentInfoRecord get() call in SAP Cloud SDK for javascript?

I use the SAP Cloud SDK for javascript to handle DocumentInfoRecords. 我使用SAP Cloud SDK for javascript处理DocumentInfoRecords。 An update of a DIR caused the error 428. So I need the etag of the request like in the SAP Cloud API. DIR的更新导致了错误428。因此,我需要像SAP Cloud API中那样请求的etag。

How can I get the etag from the GET request or generally header response information of each sdk request? 如何从GET请求或每个sdk请求的标头响应信息中获取etag?

GET: 得到:

DocumentInfoRecord.requestBuilder()
.getByKey(dir.documentInfoRecordDocType, dir.documentInfoRecordDocVersion, dir.documentInfoRecordDocNumber, dir.documentInfoRecordDocPart)
.execute({});

UPDATE with etag 用etag更新

DocumentInfoRecord.requestBuilder().update(dir).withCustomHeaders({ key: "If-Match", value: "etag" }).execute({});

UPDATE: Please see the answer of Henning Heitkötter. 更新:请参阅HenningHeitkötter的答案。


Currently we do not support eTag handling. 目前,我们不支持eTag处理。 We are aware of this shortcoming and already have it in our backlog. 我们已经意识到了这一缺点,并且已经在我们的积压中。 We will update this answer as soon as the feature is available. 该功能可用后,我们将立即更新此答案。

Since version 1.1.0, the SAP Cloud SDK for JavaScript (fka SAP S/4HANA Cloud SDK) transparently handles ETag in the background. 从1.1.0版开始,用于JavaScript的SAP Cloud SDK(fka SAP S / 4HANA Cloud SDK)在后台透明地处理ETag。 For more information, take a look at the section on optimistic concurrency control in the release blog . 有关更多信息,请参阅发行博客中有关乐观并发控制的部分。

If you update to the latest version (1.2.1 at the time of writing), you can simply retrieve the document info record, change the fields you want to change, and then update it by sending the same object to the service. 如果您更新到最新版本(在撰写本文时为1.2.1),则只需检索文档信息记录,更改要更改的字段,然后通过将同一对象发送到服务来更新它。

var dir = await DocumentInfoRecord.requestBuilder()
    .getByKey(dir.documentInfoRecordDocType, dir.documentInfoRecordDocVersion, dir.documentInfoRecordDocNumber, dir.documentInfoRecordDocPart)
    .execute({destinationName: "MyServer"});
dir.responsiblePersonName = "John Doe";
DocumentInfoRecord.requestBuilder()
    .update(dir)
    .execute({destinationName: "MyServer"})
    .then(...);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM