DigiOffice API Services Services

<back to all web services

ImportData

Import entity data into DigiOffice (v1)

Requires Authentication
The following routes are available for this service:
PUT/api/importdata
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ImportResult:
    total_rows: int = 0
    total_added: int = 0
    total_updated: int = 0
    succesfull_rows: int = 0
    error_rows: int = 0
    errors: Optional[List[str]] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ImportField:
    name: Optional[str] = None
    value: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Row:
    fields: Optional[List[ImportField]] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FixedValue:
    name: Optional[str] = None
    value: Optional[str] = None


# @Api(Description="Import entity data into DigiOffice (v1)")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ImportData:
    """
    Import entity data into DigiOffice (v1)
    """

    # @ApiMember(Description="Entityname in which the data will be imported", IsRequired=true)
    entity_type: Optional[str] = None
    """
    Entityname in which the data will be imported
    """


    # @ApiMember(Description="Reports errors with a reference to this field (for example ID)")
    error_field: Optional[str] = None
    """
    Reports errors with a reference to this field (for example ID)
    """


    # @ApiMember(Description="Should import continue on errors? (Default true)")
    continue_on_error: bool = False
    """
    Should import continue on errors? (Default true)
    """


    # @ApiMember(Description="Rows to be imported", IsRequired=true)
    rows: List[Row] = field(default_factory=list)
    """
    Rows to be imported
    """


    # @ApiMember(Description="Additional values to be imported on every row")
    fixed_values: Optional[List[FixedValue]] = None
    """
    Additional values to be imported on every row
    """

Python ImportData DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

PUT /api/importdata HTTP/1.1 
Host: test-do-services.klokgroep.nl 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<ImportData xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/IDB.API.General">
  <ContinueOnError>false</ContinueOnError>
  <EntityType>String</EntityType>
  <ErrorField>String</ErrorField>
  <FixedValues>
    <ImportData.FixedValue>
      <Name>String</Name>
      <Value>String</Value>
    </ImportData.FixedValue>
  </FixedValues>
  <Rows>
    <ImportData.Row>
      <Fields>
        <ImportData.ImportField>
          <Name>String</Name>
          <Value>String</Value>
        </ImportData.ImportField>
      </Fields>
    </ImportData.Row>
  </Rows>
</ImportData>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<ImportResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/IDB.API.General">
  <ErrorRows>0</ErrorRows>
  <Errors xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>String</d2p1:string>
  </Errors>
  <SuccesfullRows>0</SuccesfullRows>
  <TotalAdded>0</TotalAdded>
  <TotalRows>0</TotalRows>
  <TotalUpdated>0</TotalUpdated>
</ImportResult>