バッチ処理の実行
複数の操作を1つのHTTPリクエスト(バッチ・アクション)に結合して、パフォーマンスを向上させることができます。 リクエスト本文は、オブジェクトの配列である
バッチ・リクエストを使用してカスタム処理を実行することもできます。 ただし、すべてのカスタム処理がバッチ・リクエストでサポートされていない場合があります。 サポートされていないカスタム処理の場合、バッチ・リクエストにこのエラーが表示されます: partsというフィールドを持つJSONオブジェクトです。 配列の各オブジェクトには次のものが含まれます:
- 一意のID
- リソースへの相対パス
- 操作
- (オプション)ペイロード
The action {ACTION_NAME} isn't enabled for batch execution.
ノート:
フレームワークによって課されるコンカレント・リクエストおよびバッチ・サイズに制限はありません。 バッチ・リクエストの個々のパートは順番に実行されます。 ただし、操作環境には制限または制約がある場合があります。 例:- RESTサービス所有者がサービスのリクエスト・タイムアウトを構成している場合があります。 また、サーバーに汎用のリクエスト・タイムアウトが構成されている場合があります。 RESTオブジェクトが大きい場合は、バッチを介したバルク・データ処理でパフォーマンスの問題が発生します。UPSERT操作の実行時には、次の点を考慮する必要があります:
- レスポンスを必要としない場合は、次のヘッダーを使用してレスポンスを抑制できます:
Accept: application/vnd.oracle.adf.resourceitem+json;q=0 Accept-Encoding: identityこれによってレスポンスは表示されず、親レベルで式フィールドが再評価されるのを防ぎます。
- 子レコードを更新または挿入する場合は、子レコードの完全パスを
pathパラメータに含める必要があります。 たとえば、"path": "/opportunities/"ではなく"path": "/opportunities/CDRM_3341580/child/OpportunityContact/300100092629555"を使用する必要があります。
ノート:
バッチ・リクエストのペイロード内の1つの部分が失敗した場合、バッチ・アクションは基本的にすべてまたは1つのアクションであるため、他のすべての部分も暗黙的に失敗します。 特定のパーツがエラーのために失敗した場合は、エラーを含むパーツのみがレスポンスにリストされます。 エラーのない部品は、レスポンスにリストされません。 ただし、パーツ以外は処理されます。 サーバーは204ステータスを返し、この操作中に予想されます。バッチ・アクション・リクエストのJSONスキーマは次のとおりです:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"title": "Batch execution",
"description": "Group multiple requests together ('part').",
"definitions": {
"Part": {
"type": "object",
"allOf": [
{
"properties": {
"id": {
"type": "string",
"description": "An identification provided by the client to distinguish each part provided in the batch request."
},
"path": {
"type": "string",
"description": "Resource's location."
},
"operation": {
"type": "string",
"enum": [
"get",
"create",
"update",
"replace",
"delete"
],
"description": "The operation that will be performed."
},
"preconditionSucceeded": {
"type": "boolean",
"description": "This attribute is set in the batch response only when ifMatch or ifNoneMatch are provided in the request. It will be 'true' if the precondition (ifMatch/ifNoneMatch) was satisfied, otherwise 'false'."
},
"payload": {
"oneOf": [
{
"$ref": "resource-item.json",
"description": "The payload that will be used in the operation. Example: a resource instance should be provided in order to execute a 'create'."
},
{
"type": "null"
}
]
}
},
"required": [
"id",
"path",
"operation"
]
}
],
"anyOf": [
{
"properties": {
"ifMatch": {
"type": "string",
"description": "This attribute is analogous to the If-Match header. It represents a precondition to execute this operation. The value can be null (same effect of 'If-Match: *') or an array of resource versions."
}
}
},
{
"properties": {
"ifNoneMatch": {
"type": "string",
"description": "This attribute is analogous to the If-None-Match header. It represents a precondition to execute this operation. The value can be null (same effect of 'If-None-Match: *') or an array of resource versions."
}
}
}
],
"description": "Represents a request."
}
},
"properties": {
"parts": {
"type": "array",
"items": {
"$ref": "#/definitions/Part"
},
"description": "Array that represents multiple requests."
}
},
"required": [
"parts"
]
}
例: 既存の商談の取得、新規商談の作成、および商談担当者の取得
このリクエストでは、既存の取引先を取得し、新しい取引先を作成し、セールス・チーム・メンバーの詳細を取得します:
ノート:
子レコードを更新または挿入する場合は、pathパラメータに子レコードの完全パスを含める必要があります。 たとえば、"path": "/opportunities/"ではなく"path": "/opportunities/CDRM_3341580/child/OpportunityContact/300100092629555"を使用する必要があります。
curl \
https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/ \
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-H 'Content-Type: application/vnd.oracle.adf.batch+json'
{
"parts": [
{
"id": "part1",
"path": "/opportunities/CDRM_93472",
"operation": "get"
},
{
"id": "part2",
"path": "/opportunities",
"operation": "create",
"payload": {
"Name" : "Major Application Upgrade"
}
}
{
"id": "part3",
"path": "/opportunities/CDRM_3341580/child/OpportunityContact/300100092629555",
"operation": "get"
}
]
}
レスポンス本文には結果が含まれ、リクエストと同じメディア・タイプが使用されます。
{
"parts": [
{
"id": "part1",
"path": "/opportunities/CDRM_93472",
"operation": "get"
"payload" : {
"BudgetAvailableDate": null,
"BudgetedFlag": false,
"PrimaryOrganizationId": 204,
"ChampionFlag": false,
"CreatedBy": "SALES_ADMIN",
"CreationDate": "2018-01-08T12:00:24.972+00:00",
"CurrencyCode": "USD",
"SalesMethodId": 300100073102472,
"SalesStageId": 300100073102473,
"CustomerAccountId": null,
"DealHorizonCode": null,
"DecisionLevelCode": null,
"Description": null,
"LastUpdateDate": "2018-01-08T12:24:05.310+00:00",
"LastUpdatedBy": "SALES_ADMIN",
"LastUpdateLogin": "6242B5ED93BE3EC9E0539EBDF20ABB8B",
"Name": "Big Data Analytics Servers",
"OptyId": 300100125332293,
"OptyNumber": "CDRM_93472",
},
},
{
"id": "part2",
"path": "/opportunities",
"operation": "create",
"payload" : {
BudgetAvailableDate: null
BudgetedFlag: false
PrimaryOrganizationId: 204
ChampionFlag: false
CreatedBy: "SALES_ADMIN"
CreationDate: "2015-06-04T03:08:27-07:00"
CurrencyCode: "USD"
SalesMethodId: 100000012430001
SalesStageId: 100000012430007
Name: "Major Application Upgrade"
OptyId: 300100111705686
OptyNumber: "CDRM_332708"
}
{
"id": "part3",
"path": "/opportunities/CDRM_3341580/child/OpportunityContact/300100092629555",
"operation": "get"
"payload" : {
AffinityLvlCd: null,
Comments: null,
ContactedFlg: "N",
PartyName: "Juan BELL",
OptyConId: 300100092629555,
PERPartyId: 100000018544431,
CreatorPartyId: 100010025532672,
CreatedBy: "MHoope",
CreationDate: "2016-11-16T05:15:38-08:00",
LastUpdateDate: "2016-11-16T05:15:43-08:00",
ContactPointId: 100000018544441,
FormattedAddress: "1625 19th Ave,SEATTLE, WA 98122",
FormattedPhoneNumber: "2065584951",
ContactPartyNumber: "100000018544430",
...
}
}
]
}
例: 既存の営業テリトリの取得および別の営業テリトリの更新
このリクエストでは、既存の営業テリトリを取得し、別の営業テリトリの詳細を更新します:
curl \
https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/ \
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-H 'Content-Type: application/vnd.oracle.adf.batch+json'
{
"parts": [
{
"id": "part1",
"path": "/territories/100000015312131",
"operation": "get"
},
{
"id": "part2",
"path": "/territories/300100128873880",
"operation": "update",
"payload": {
"Name":"Rest_Terr_Updated",
"Description" : "Updating a Draft Territory"
}
}
]
}
レスポンス本文には結果が含まれ、リクエストと同じメディア・タイプが使用されます。
{
"parts":[
{
"id":"part1",
"path":"/territories/100000015312131",
"operation":"get",
"payload" :{
"EffectiveEndDate": "4713-01-31"
"EffectiveStartDate": "2010-01-13"
"Name": "APAC Sales QA Organization Type"
"TerritoryVersionId": 100000015312131
"OwnerResourceId": 100010032635399
...
}
},
{
"id" : "part2",
"path" : "/territories/300100128873880",
"operation" : "update",
"payload" : {
"Description": "Updating a Draft Territory",
"EffectiveEndDate": null,
"EffectiveStartDate": null,
"Name": "Rest_Terr_Updated",
"TerritoryVersionId": 300100091635502,
"OwnerResourceId": 100010025532672,
...
}
}
]
}
例: 複数の購買オーダー明細のクローズ
このリクエストは、バッチ内の複数の購買オーダー明細をクローズします:
curl \
http://servername:fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/ \
-H Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=??? \
-H Content-Type: application/vnd.oracle.adf.batch+json???
{
"parts":[
{
"id" : "part1",
"path" : "purchaseOrders/100000019476400/child/lines/702260/action/close",
"operation" : "invoke",
"payload" :{
{
"closeAction" : "closeForReceiving"
},
{
"closeReason" : "Close for receiving reason line 1"
}
}
},
{
"id" : "part2",
"path" : "purchaseOrders/100000019476400/child/lines/702261/action/close",
"operation" : "invoke",
"payload" :{
{
"closeAction" : "closeForReceiving"
},
{
"closeReason" : "Close for receiving reason line 2"
}
}
}
]
}
例: 複数のサブスクリプションに対する複数の製品の作成
このリクエストでは、複数のサブスクリプションの複数の製品をバッチで作成できます:
https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05 \
-H 'Method: POST' \
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-H 'Content-Type: application/vnd.oracle.adf.batch+json'
{ "parts": [
{
"id": "part1-21002",
"path": "/subscriptions/21002/child/products",
"operation": "create",
"payload": {
"ProductName":"KiDT256GB_W",
"LineNumber":3
}
},
{
"id": "part2-21002",
"path": "/subscriptions/21002/child/products",
"operation": "create",
"payload": {
"ProductName":"SUBSCRIPTION ITEM",
"LineNumber":4
}
}
]
}
レスポンス本文には結果が含まれ、リクエストと同じメディア・タイプが使用されます。
{
"parts": [
{
"id": "part1-21002",
"path": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/subscriptions/21002/child/products",
"operation": "create",
"payload": {
"SubscriptionProductId": 300000264330468,
"SubscriptionId": 300000056319703,
"LineNumber": "3",
"SubscriptionProductPuid": "21002-PRDT-154068",
"DefinitionOrganizationId": 300000001621747,
"SubscriptionNumber": "21002",
"SalesProductType": "COVERAGE",
"Description": "Extended warranty for Kingston DT 256GB",
"InventoryItemId": 300000002191542,
"ItemUnitOfMeasure": "YR",
"ProductName": "KiDT256GB_W",
"Quantity": 1,
"StartDate": "2019-08-23",
"EndDate": null,
"CloseReason": null,
"CloseCreditMethod": null,
"CancelReason": null,
"ClosedDate": null,
"CanceledDate": null,
"RenewedDate": null,
"PriceListId": null,
"UnitPrice": null,
"Status": "ORA_DRAFT",
"Currency": "USD",
"InvoicingRuleId": -2,
"InvoicingRuleName": "Advance Invoice",
"BillOnDay": null,
"BillingOffsetDays": null,
"BillingFrequency": "YR",
"BillingFrequencyName": "Year",
"AccountingRuleId": -104,
"AccountingRuleName": "12 Months Fixed",
"TransactionTypeName": "Invoice",
"InvoiceText": "[$Product Name]: [$Charge Name] [$Bill from Date]-[$Bill to Date]",
"BillToPartyId": 300000004212903,
"BillToPartyNumber": "22610",
"BillToAccountId": 300000004212905,
"BillToAccountNumber": "21022",
"BillToAccountDescription": "BA_CUST_STATEMENT",
"BillToSiteUseId": 300000004212910,
"BillToAddress": "Main Street,NEW YORKNY10001NEW YORK,US",
"ShipToPartyId": null,
"ShipToPartyName": null,
"ShipToPartySiteId": null,
"ShipToPartySiteName": null,
"PaymentMethod": null,
"PaymentMethodName": null,
"PONumber": null,
"WireNumber": null,
"PaymentTermsId": 4,
"PaymentTermsName": "30 Net",
"PrePaymentNumber": null,
"TaxExemptionHandling": "S",
"TaxExemptionHandlingName": "Standard",
"ExemptCertificateNumber": null,
"ExemptReason": null,
"OutputTaxClassification": null,
"ProductFiscClassification": null,
"TaxError": null,
"CoverageScheduleId": null,
"RenewalType": "RENEW",
"BillingDateCode": "ORA_PERIOD_START",
"BillingDateName": "Period start",
"TotalContractValue": null,
"EstimatedTax": null,
"PricingError": null,
"PriceAsOf": "2022-09-27",
"PriceTransactionOn": "2022-09-27",
"InvoicedAmount": null,
"CreditedAmount": null,
"CanceledAmount": null,
"ClosedAmount": null,
"SourceSystem": null,
"SourceKey": null,
"SourceNumber": null,
"SourceLineKey": null,
"SourceLineNumber": null,
"MonthlyRecurringRevenue": null,
"Duration": null,
"Period": null,
"GenerateBillingSchedule": null,
"ExternalAssetKey": null,
"ExternalParentAssetKey": null,
"ExternalPriceListId": null,
"ExternalRootAssetKey": null,
"PriceListName": null,
"NextPricingDate": null,
"PricingTermsStartDate": null,
"PricingTermsPricingMethod": null,
"PricingTermsPeriod": null,
"PricingTermsDuration": null,
"PricingTermsAdjustmentPCT": null,
"CorpCurrencyCode": "USD",
"CurcyConvRateType": "Corporate",
"AmendCreditMethod": null,
"AmendCreditMethodName": null,
"AmendDescription": null,
"AmendEffectiveDate": null,
"AmendReason": null,
"AmendReasonName": null,
"StatusMeaning": "Draft",
"EnablePricingTermsFlag": null,
"NextBillStartDate": null,
"TaxClassificationMeaning": null,
"CreatedBy": "alexandra.rabaea",
"CreationDate": "2022-09-27T08:28:09+00:00",
"LastUpdatedBy": "alexandra.rabaea",
"LastUpdateDate": "2022-09-27T08:28:13.006+00:00",
"LastUpdateLogin": "E2CE626179F963F0E0538AED3C0A1A5F",
"SummarizedBillingFlag": null,
"InterfaceOffsetDays": null,
"CoverageName": null,
"SuspendReason": null,
"SuspendedDate": null,
"SuspendCreditMethod": null,
"ResumeDate": null,
"ResumeDuration": null,
"ResumePeriod": null,
"AutoExtendFlag": null,
"ChurnProbability": null,
"EarlyTerminationPenalty": null,
"EarlyTerminationFee": null,
"GracePeriod": null,
"PenaltyValue": null,
"PenaltyChargeName": "Penalty Fee",
"EarlyTerminationPenaltyName": null,
"ChurnPredictionTrend": null,
"PriceAdjustmentType": null,
"PriceAdjustmentBasis": null,
"PriceAdjustmentPercent": null,
"DisplaySequence": null,
"RelatedInventoryItemId": null,
"RelatedProductName": null,
"ProductChangeReason": null,
"ProductChangeSchedule": null,
"ProductChangeScheduleFrom": null,
"DropOneTimeChargeFlag": null,
"RelatedProductDescription": null,
"GenerateBillFullPeriodFlag": null,
"RenewalPaymentMethod": null,
"RenewalPoNumber": null,
"RenewalWireNumber": null,
"RenewalPaymentMethodName": null,
"CustomerTrxTypeSequenceId": null,
"RepriceFlag": null,
"AlignBillingFrom": null,
"PendingActivationFlag": null,
"RatePlanDocumentId": null,
"RatePlanId": null,
"RatePlanNumber": null,
"RatePlanName": null,
"BillToSiteNumber": null,
"ShipToPartyNumber": null,
"ShipToPartySiteNumber": null,
"SalesOrderId": null,
"SalesOrderNumber": null,
"OrderFulfillLineId": null,
"OrderFulfillLineNumber": null,
"EnableUpfrontBillingFlag": null,
"BillToContactId": null,
"ShipToAccountId": null,
"ShipToContactId": null,
"WarehouseId": null,
"BillToPartyName": "BA_CUST_STATEMENT",
"BillToContactName": null,
"ShipToAccountNumber": null,
"ShipToContactName": null,
"WareHouseName": null,
"ShipToAccountDescription": null,
"BillToContactNumber": null,
"ShipToContactNumber": null,
"ShipToContactPartyId": null,
"UsageInvoiceLayoutTemplate": null,
"EnableProrateByDay": null,
"RequestedRatePlanId": null,
"RequestedRatePlanNumber": null,
"RenewalDuration": null,
"RenewalDurationPeriod": null,
"RenewalDurationPeriodName": null,
"DefaultRevenueAction": null,
"OverrideCreditAmount": null,
"CalculatedCreditAmount": null,
"TrackingId_c": null,
"links": [
...
}
バッチ・プロセスは、タスクをより迅速かつ効率的に実行するのに役立ちます。