Skip to main content

Return Values

Answers to Creating Records

Written by Lenka Haringerová

In this tutorial, we will look at return values. In the two previous articles, you learned how to create new records in ABRA Flexi — this article will reveal what ABRA Flexi returns in response to that action.

Flexi returns a structure in response to a PUT or POST request that informs the user about the changes made.

If you send data to an XML endpoint, ABRA Flexi will return the structure in XML format.

<?xml version="1.0"?><winstrom version="1.0">  <success>true</success>  <stats>    <created>1</created>    <updated>0</updated>    <deleted>0</deleted>    <skipped>0</skipped>    <failed>0</failed>  </stats>  <results>    <result>      <id>804</id>      <ref>/c/demo/adresar/804.xml</ref>    </result>  </results></winstrom>

However, if you choose a JSON endpoint, the system will also return the response value in JSON format.

{    "winstrom": {        "@version": "1.0",        "success": "true",        "stats": {            "created": "1",            "updated": "0",            "deleted": "0",            "skipped": "0",            "failed": "0"        },        "results": [            {                "id": "805",                "ref": "\/c\/demo\/adresar\/805.json"            }        ]    }}

Return values can be processed to extract the information you need.

The return value contains the following fields:

1. success

Possible values are true and false. If the write operation was successful, the return value is true. If an error occurred during the write operation, ABRA Flexi returns false.

2. stats

Flexi also returns statistics containing information about how many objects were created (created), modified (updated), deleted (deleted), skipped (skipped), and how many objects could not be inserted due to an error (failed).

3. results

This collection contains the identifiers of objects that were created in ABRA Flexi, as well as any error messages associated with individual objects.

<?xml version="1.0"?><winstrom version="1.0">  <success>false</success>  <stats>    <created>0</created>    <updated>0</updated>    <deleted>0</deleted>    <skipped>0</skipped>    <failed>1</failed>  </stats>  <results>    <result>      <errors>        <error for="kod" code="INVALID"> Zkratku 'CHARLIEB' ji&#x17E; pou&#x17E;&#xED;v&#xE1; jin&#xFD; z&#xE1;znam. [CHARLIEB] </error>      </errors>    </result>  </results></winstrom>

An example of an error XML return value.

{    "winstrom": {        "@version": "1.0",        "success": "false",        "stats": {            "created": "0",            "updated": "0",            "deleted": "0",            "skipped": "0",            "failed": "1"        },        "results": [            {                "errors": [                    {                        "message": "Zkratku 'CHARLIEB' ji\u017e pou\u017e\u00edv\u00e1 jin\u00fd z\u00e1znam. [CHARLIEB]",                        "for": "kod",                        "code": "INVALID"                    }                ]            }        ]    }}

An example of an error JSON return value.

Your application can therefore immediately determine what happened in ABRA Flexi. It can check whether all objects were successfully created, and in the event of an error, display an error message to the user and allow them to correct the data.

Did this answer your question?