My Products
Help
Florian Haase
PARTNER

Strange error posting Budget

by Florian Haase

Hi,

 

We are trying to post a budget line for our customer and we get an HTTP/1.1 500 Internal Server Error.

I have verified the JSON in a JSON verifier - that is ok. I get the same error when I use Swaggar.

The error is

{

  "message": "VismaId: 0251b020-2d21-4a09-b4bf-dd766657a4b3. Error creating budget. Index and length must refer to a location within the string.\r\nParameter name: length"

}

 

It works in user interface.

 

 

Json:

{"ledger": {"value": "2"},"financialYear": {"value": "2021"},"account": {"value": "1110"},"subaccount":[{"segmentId": 1,"segmentValue": "100"},{"segmentId": 2,"segmentValue": "00"},{"segmentId": 3,"segmentValue": "80901"},{"segmentId": 4,"segmentValue": "00"} ],"description": {"value": "Budsjett 2021"},"amount": {"value": -958333.26},"branchNumber": {"value": "1"},"periods":[{"operation": "Insert","periodId": {"value": "1"},"amount": {"value": -95833.33}},{"operation": "Insert","periodId": {"value": "2"},"amount": {"value": -95833.33}},{"operation": "Insert","periodId": {"value": "3"},"amount": {"value": -95833.33}},{"operation": "Insert","periodId": {"value": "4"},"amount": {"value": -95833.33}},{"operation": "Insert","periodId": {"value": "5"},"amount": {"value": -95833.33}},{"operation": "Insert","periodId": {"value": "6"},"amount": {"value": -95833.33}},{"operation": "Insert","periodId": {"value": "7"},"amount": {"value": -95833.33}},{"operation": "Insert","periodId": {"value": "8"},"amount": {"value": -95833.33}},{"operation": "Insert","periodId": {"value": "9"},"amount": {"value": -95833.33}},{"operation": "Insert","periodId": {"value": "10"},"amount": {"value": -95833.33}},{"operation": "Insert","periodId": {"value": "11"},"amount": {"value": -95833.33}},{"operation": "Insert","periodId": {"value": "12"},"amount": {"value": -95833.33}} ]}

 

 

Reponse: 

HTTP/1.1 500 Internal Server Error
Date: Fri, 30 Apr 2021 06:15:50 GMT
Server: Apache/2.4.25 (Debian)
Strict-Transport-Security: max-age=31536000; includeSubDomains
Content-Type: application/json; charset=utf-8
ipp-request-id: 53f689c4-ff13-4b0a-a789-8ad58c2f85e8
Feature-Policy: geolocation 'none'; vr 'none'; payment 'none'; midi 'none'; microphone 'none'; fullscreen 'none'; encrypted-media 'none'; camera 'none'; autoplay 'none';
Cache-Control: no-cache,no-cache
X-Content-Type-Options: application/json
Pragma: no-cache
X-Handled-By: Acumatica-PX.Export/AuthenticationManagerModule
Referrer-Policy: origin-when-cross-origin
VnfInstanceId: ERP_NO_REAL_0027
Strict-Transport-Security: max-age=31536000; includeSubDomains
Expires: -1
X-XSS-Protection: 1;mode=block
Set-Cookie: LegacyUI=0; path=/; secure; HttpOnly,UserBranch=13; path=/; secure; HttpOnly,Locale=TimeZone=GMTE0000U&Culture=en-GB; path=/; secure; HttpOnly,LicenseRoles=; expires=Thu, 29-Apr-2021 06:15:49 GMT; path=/; secure; HttpOnly,UserDisplayName=; expires=Thu, 29-Apr-2021 06:15:49 GMT; path=/; secure; HttpOnly,ADRUM_BT1=R:0|i:309592; expires=Fri, 30-Apr-2021 06:16:19 GMT; path=/; secure; HttpOnly,ADRUM_BTa=R:0|g:ec02fe20-992a-42f2-96d1-76ec88302a3e|n:visma_33a6117b-0ef0-4014-a5c1-a5af28a665ec; expires=Fri, 30-Apr-2021 06:16:19 GMT; path=/; secure; HttpOnly
Set-Cookie: ADRUM_BT1=R:0|i:107258|e:898|d:1053; Expires=Fri, 30-Apr-2021 06:18:10 GMT; Path=/
Connection: close

 

Content:

{"message":"VismaId: 337521c0-18b3-4573-acea-ead68b9dcc40. Error creating budget. Index and length must refer to a location within the string.\r\nParameter name: length"}

 

Regards,

 

Florian

5 REPLIES 5

by Magnus Johnsen (Updated ‎30-04-2021 12:05 by Magnus Johnsen VISMA )

Hi,

Could you please doublecheck your sub account segment key setup(ScreenId=CS202000&DimensionID=SUBACCOUNT):

2021-04-30 12_00_55-Segment keys.png

It sounds like there is a value sent that is longer or shorter than the length specified for the value. 

Florian Haase
PARTNER

by Florian Haase

Checked and its correct.

Here is from an Get subaccount

{

    "subaccountNumber": "100008090100",

    "subaccountId": 109617,

    "lastModifiedDateTime": "2021-04-28T21:26:08.783",

    "active": true,

    "segments": [

      {

        "segmentId": 1,

        "segmentDescription": "OmrÃ¥de",

        "segmentValue": "100",

        "segmentValueDescription": "Felles"

      },

      {

        "segmentId": 2,

        "segmentDescription": "Inntekt- og kostnadssted",

        "segmentValue": "00",

        "segmentValueDescription": "Ingen"

      },

      {

        "segmentId": 3,

        "segmentDescription": "Objekt",

        "segmentValue": "80901",

        "segmentValueDescription": "Ford.farled"

      },

      {

        "segmentId": 4,

        "segmentDescription": "Attestering",

        "segmentValue": "00",

        "segmentValueDescription": "Ingen"

      }

    ],

    "metadata": {

      "totalCount": 425,

      "maxPageSize": 1000

    }

  },

Accepted solution
Magnus Johnsen
VISMA

by Magnus Johnsen (Updated ‎06-05-2021 12:13 by Magnus Johnsen VISMA )

Hi Florian,

The issue is that the periodId's under periods should be defined as YYYYMM.

Here is the updated version that I used in my local company:

{
    "ledger": {
        "value": "TEST"
    },
    "financialYear": {
        "value": "2021"
    },
    "account": {
        "value": "1910"
    },
    "subaccount": [
        {
            "segmentId": 1,
            "segmentValue": "01"
        },
        {
            "segmentId": 2,
            "segmentValue": "001"
        },
        {
            "segmentId": 3,
            "segmentValue": "1"
        }
    ],
    "description": {
        "value": "Budsjett 2021"
    },
    "amount": {
        "value": -958333.26
    },
    "branchNumber": {
        "value": "TEST"
    },
    "periods": [
        {
            "operation": "Insert",
            "periodId": {
                "value": "202101"
            },
            "amount": {
                "value": -95833.33
            }
        },
        {
            "operation": "Insert",
            "periodId": {
                "value": "202102"
            },
            "amount": {
                "value": -95833.33
            }
        },
        {
            "operation": "Insert",
            "periodId": {
                "value": "202103"
            },
            "amount": {
                "value": -95833.33
            }
        },
        {
            "operation": "Insert",
            "periodId": {
                "value": "202104"
            },
            "amount": {
                "value": -95833.33
            }
        },
        {
            "operation": "Insert",
            "periodId": {
                "value": "202105"
            },
            "amount": {
                "value": -95833.33
            }
        },
        {
            "operation": "Insert",
            "periodId": {
                "value": "202106"
            },
            "amount": {
                "value": -95833.33
            }
        },
        {
            "operation": "Insert",
            "periodId": {
                "value": "202107"
            },
            "amount": {
                "value": -95833.33
            }
        },
        {
            "operation": "Insert",
            "periodId": {
                "value": "202108"
            },
            "amount": {
                "value": -95833.33
            }
        },
        {
            "operation": "Insert",
            "periodId": {
                "value": "202109"
            },
            "amount": {
                "value": -95833.33
            }
        },
        {
            "operation": "Insert",
            "periodId": {
                "value": "202110"
            },
            "amount": {
                "value": -95833.33
            }
        },
        {
            "operation": "Insert",
            "periodId": {
                "value": "202111"
            },
            "amount": {
                "value": -95833.33
            }
        },
        {
            "operation": "Insert",
            "periodId": {
                "value": "202112"
            },
            "amount": {
                "value": -95833.33
            }
        }
    ]
}
Florian Haase
PARTNER

by Florian Haase

Yes this solved the problem, thank you!

A better errordescription would make it easier to understand what the problem is 🙂

But now the import works...

 

 

by Magnus Johnsen

Indeed, good to hear that it works!