Create customer via batch
In this example we will simulate creation of a customer, add a reference to it, update some properties on the customer then finally get a snapshot of what it looks like all within the same transaction using the batch command API endpoint.
See the reference documentation for more information about the commands used in this example:
Request
POST /sv/004.1/api/v1/Batch/Simulate HTTP/1.1
Host: localhost:8001
Content-Type: application/json
Cache-Control: no-cache
Accept: application/json
X-Monitor-SessionId: {sessionId}
[
{
"Path": "Sales/Customers/Create",
"Body": { "Name": "Example customer", "Code": "EXMPL" },
"ForwardPropertyName": "RootEntityId",
"ReceivingPropertyName": null
},
{
"Path": "Sales/Customers/AddReference",
"Body": { "Name": { "Value": "Reference name" } },
"ForwardPropertyName": "RootEntityId",
"ReceivingPropertyName": "CustomerId"
},
{
"Path": "Sales/Customers/SetProperties",
"Body": { "DeliveryInstruction": { "Value": "Requires discrete delivery." } },
"ForwardPropertyName": "RootEntityId",
"ReceivingPropertyName": "CustomerId"
},
{
"Path": "Common/Commands/GetEntity",
"Body": { "Path": "Sales/Customers", "Expands": [ "References" ] },
"ForwardPropertyName": null,
"ReceivingPropertyName": "EntityId"
}
]
Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"$id": "1",
"$type": "Monitor.API.Infrastructure.BatchResponse, Monitor.API",
"IsSuccessful": true,
"Response": [
{
"$id": "2",
"$type": "Monitor.API.Infrastructure.EntityCommandResponse, Monitor.API",
"RootEntityId": "380497447683684471",
"EntityId": "380497447683684471",
"CommandName": "CreateCustomer",
"Data": null
},
{
"$id": "3",
"$type": "Monitor.API.Infrastructure.EntityCommandResponse, Monitor.API",
"RootEntityId": "380497447683684471",
"EntityId": "380497447683684461",
"CommandName": "AddCustomerReference",
"Data": null
},
{
"$id": "4",
"$type": "Monitor.API.Infrastructure.EntityCommandResponse, Monitor.API",
"RootEntityId": "380497447683684471",
"EntityId": "380497447683684471",
"CommandName": "SetPropertiesCustomer",
"Data": null
},
{
"$id": "5",
"$type": "Monitor.API.Infrastructure.EntityCommandResponse, Monitor.API",
"RootEntityId": "380497447683684471",
"EntityId": "380497447683684471",
"CommandName": "GetEntity",
"Data": "{\"Id\":380497447683684471,\"Name\":\"Example customer\",\"Code\":\"EXMPL\",\"AlternativeName\":null,\"CorporationIdentificationNumber\":null,\"IsPrivateCustomer\":false,\"PersonalNumber\":null,\"VatNumber\":null,\"MailingAddressId\":380497447683684460,\"AccountManagerId\":null,\"ActualCustomerProbabilityId\":null,\"Alias\":\"EXMPL\",\"AlloyCost\":0,\"ApplyBankCharge\":false,\"ApplyInvoicingCharge\":false,\"ApplyReminderCharge\":false,\"AttachDatafileWithDispatchAdvice\":true,\"AttachDatafileWithInvoice\":true,\"AttachDatafileWithOrder\":true,\"AttachDatafileWithPart\":true,\"BankChargeAmount\":0.00000000,\"BankGiroNo\":null,\"BlockedById\":null,\"BlockedContextType\":0,\"BlockedFromDate\":null,\"BlockedStatus\":0,\"BlockedToDate\":null,\"BlockMessageId\":null,\"CategoryString\":null,\"CommentId\":null,\"CompanyId\":1,\"ConfigurationPriceListId\":null,\"CreditLimit\":0.00000000,\"CurrencyId\":1,\"DateForTransitionToActualContact\":\"2018-08-22T10:44:25.665425+02:00\",\"DefaultInvoiceStatusPending\":false,\"DefaultOrderPrintoutVia\":1,\"DefaultReferenceId\":null,\"DeliveryInstruction\":\"Requires discrete delivery.\",\"Discount\":0.00000000,\"DiscountCategoryId\":null,\"DistrictId\":null,\"EdiCode\":null,\"Factoring\":false,\"GracePeriod\":null,\"InsuranceCost\":0.00000000,\"InterestInvoiceDays\":null,\"InterestType\":0,\"InvoiceCustomerId\":null,\"InvoicePrintoutMethod\":1,\"InvoicePrintoutOccasion\":0,\"IsCasualCustomer\":false,\"LanguageId\":1,\"LatePaymentFee\":null,\"NumberOfInvoiceCopies\":null,\"OurCodeByYou\":null,\"PalletRegistrationNo\":null,\"PaymentTermId\":1,\"PickingListCommentId\":null,\"PlusGiroNo\":null,\"PriceListId\":1,\"Priority\":9,\"ProformaInvoicePrintoutOccasion\":1,\"ResellerId\":null,\"RoundOff\":true,\"SellerId\":null,\"ServiceAgreementId\":null,\"ShowPartStatisticalGoodsCodeAndCountryOfOriginInForms\":0,\"ShowPartWeightInForms\":0,\"StatusId\":1,\"ToleranceForEarlyDelivery\":null,\"ToleranceForLateDelivery\":null,\"TypeId\":null,\"Url\":null,\"UseComprehensiveInvoices\":false,\"UseDeliveryNoteCollectionFormReport\":false,\"UseForwardRate\":false,\"UseInvoiceCustomersVatNumber\":false,\"UseReminder\":true,\"ValidityTimeId\":1,\"VatRateId\":null,\"Version\":2,\"VisitingAddressId\":null,\"InvoiceAddressId\":null,\"ActiveDeliveryAddressId\":380497447683684456,\"References\":[{\"Id\":380497447683684461,\"Category\":null,\"CommentId\":null,\"ExtraInformation1\":null,\"ExtraInformation2\":null,\"ExtraInformation3\":null,\"Name\":\"Reference name\",\"Note\":null,\"CellPhoneNumber\":null,\"EmailAddress\":null,\"FaxNumber\":null,\"PhoneNumber\":null}]}"
}
],
"FailingIndex": null,
"ErrorMessage": null
}