Skip to main content

Setup/Change Mode

Creating and Updating a Record in the REST API

Written by Lenka Haringerová

When importing a record, you can specify behavior depending on whether the record already exists. This lets you ensure that a related record is only imported if it doesn't already exist. If it already exists, the user may have already modified it, so we won't import it again and overwrite the values.

The mode can be specified separately for each record and also for each operation (create/update):

<winstrom version="1.0">
<faktura-vydana update="ignore">
<id>123</id>
...
</faktura-vydana>
</winstrom>


Modes for creating and updating

Operation

Mode

Description

Create
(create)

ignore

If the record does not exist, ignore the request to create it.

fail

If the record does not exist, fail.

ok

If the record does not exist, create it normally. Default value.

Update
(update)

ignore

If the record already exists, ignore the request to update it.

fail

If the record already exists, fail.

ok

If the record already exists, update it normally. Default value.

ℹ️ How to recognize modes in the response: with ignore, the server responds 200, but returns no <id> — the record was skipped. With fail, it responds 400 with message code importXmlCreateNeniPovolen, resp. importXmlUpdateNeniPovolen.


Behavior for an unresolved relation

A similar mechanism to the one used for skipping rows can also be used for relations:

<winstrom version="1.0">
<faktura-vydana>
<firma if-not-found="null">code:FIRMA</firma>
...
</faktura-vydana>
</winstrom>

In this case, if a company with the code FIRMA is not found, the relation will instead be set to null (i.e., empty).

Value

Description

null

If the record does not exist, do not set the relation.

nearest-invalid

If the record referenced by the code does not currently exist but existed in the past, the relation is made to the most recent no-longer-valid record. The date used is the document date, event date, etc. This is useful, for example, when importing historical documents linked to account numbers that are no longer valid.

create

If the record referenced by the code does not exist, it is created automatically. For code-list type records, the code / name properties are filled in based on the reference value (e.g., FIRMA / FIRMA - Vyplněno při importu). Records with other required properties cannot be created this way.

⚠️ Without the if-not-found attribute, a reference to a non-existent record will result in the error 400. So if you're importing data from a foreign system where relations may not be complete, include this attribute — otherwise the entire import will fail.


Related

Did this answer your question?