My Products
Help
Snuffsis
CONTRIBUTOR ***

SalesOrder V3 subaccount formatting issue

by Snuffsis (Updated ‎05-12-2022 15:04 by Snuffsis )

We're now trying to prepare for next year with the new SalesOrder V3 endpoint and so far it's gone okay.

 

But when we are trying out the SalesOrder endpoint for creating a new SalesOrder, we are running into an issue regarding subaccounts.

 

If we omit the subaccount fields, we get this:

 

{
	"details": [
		{
			"code": "1202-SegmentValueNotFound",
			"message": "Subaccount segment values not found: SegmentId: 1 and Value 0, SegmentId: 2 and Value 0, SegmentId: 3 and Value 0, SegmentId: 4 and Value 0, SegmentId: 5 and Value 0, SegmentId: 6 and Value 0, SegmentId: 7 and Value 0, SegmentId: 8 and Value 0, SegmentId: 9 and Value 0, SegmentId: 10 and Value 0",
			"parameters": {
				"property": "orderLines.subaccount"
			}
		}
	],
	"errors": {
		"DomainValidation": [
			"Subaccount segment values not found: SegmentId: 1 and Value 0, SegmentId: 2 and Value 0, SegmentId: 3 and Value 0, SegmentId: 4 and Value 0, SegmentId: 5 and Value 0, SegmentId: 6 and Value 0, SegmentId: 7 and Value 0, SegmentId: 8 and Value 0, SegmentId: 9 and Value 0, SegmentId: 10 and Value 0"
		]
	},
	"title": "One or more validation errors occurred.",
	"status": 400,
	"detail": "Refer to the errors property for additional details",
	"instance": "/api/v3/SalesOrders"
}

 

The json input:

 

{
	"customer": {
		"id": "0021",
		"order": "000113"
	},
	"type": "SO",
	"description": "sample request order",
	"orderLines": [
		{
			"inventoryId": "0001",
			"quantity": 4,
			"unitPrice": 101.25
		}
	]
}

 

If we add the subaccount fields as per the swagger documentation, we get this:

 

 

{
	"details": [
		{
			"code": "0003-InvalidValue",
			"message": "The JSON value could not be converted to System.Int32. Path: $.orderLines[0].subaccount.additionalProp1 | LineNumber: 13 | BytePositionInLine: 22.",
			"parameters": {
				"property": "$.orderLines[0].subaccount.additionalProp1"
			}
		}
	],
	"errors": {
		"$.orderLines[0].subaccount.additionalProp1": [
			"The JSON value could not be converted to System.Int32. Path: $.orderLines[0].subaccount.additionalProp1 | LineNumber: 13 | BytePositionInLine: 22."
		]
	},
	"title": "One or more validation errors occurred.",
	"status": 400,
	"detail": "Refer to the errors property for additional details",
	"instance": "/api/v3/SalesOrders"
}

 

the json input:

 

{
	"customer": {
		"id": "0021",
		"order": "000113"
	},
	"type": "SO",
	"description": "sample request order",
	"orderLines": [
		{
			"inventoryId": "0001",
			"quantity": 4,
			"unitPrice": 101.25,
			"subaccount": {
				"additionalProp1": 00,
				"additionalProp2": 000000,
				"additionalProp3": 00
			}
		}
	]
}

 

We also tried inputting the values as both string and integer, same problem.
We have also checked in the company settings if the subaccounts are enabled and existing. (we also saw the other post about this and checked that), and it all seems fine.

 

in the article information:

Snuffsis_0-1670248628179.png

in the list of koddelar (GL203000)

Snuffsis_1-1670248659019.png

 

And in CS203000 with ID=SUBACCOUNT they all exist there as well.

Creating the salesOrder for the same customer with the same article manually in the UI is working fine.

4 REPLIES 4
Snuffsis
CONTRIBUTOR ***

by Snuffsis

The solution was provided above, and it was just an issue with how swagger prints out examples.

 

If it isn't too breaking of a change. Since subaccount can contain a varying amount of segments, wouldn't it make more sense that it was a list instead?

Something like:

[
  {
    "id": "string",
    "value": "string"
  },
  {
    "id": "string",
    "value": "string"
  }
]

 

Accepted solution
adrianm
PARTNER

by adrianm

Subaccount is a dictionary of number, id

 

"subaccount":{ "1": "00", "2": "107", "3": "00"}

 

(additionalProp is just something the Swagger GUI shows when names are not fixed)

Snuffsis
CONTRIBUTOR ***

by Snuffsis

Oh right, thanks for the reminder.

 

 

Donia
PARTNER

by Donia (Updated ‎06-12-2022 09:02 by Donia PARTNER )

I came across the same problem but i solved it like this and it worked for me, i don't know if it will help you:

View more
{
    "customer": {
      "id": "10000",
      "order": "some-customer-order-nbr"
    },
    "type": "SO",
    "description": "sample request order",
    "status": "Hold",
    "orderLines": [
        {
            "inventoryId": "101010",
            "quantity": 3,
            "unitPrice": 100,
            "subaccount": {
              "1": "0",
              "2": "00"
           }
        }
    ]
}

Donia_1-1670313492729.png