to get a personalized navigation.
to get a personalized navigation.
We are running in to an issue when trying to create a segment / Sales order, see details and steps below:
I've found that "subaccount" value we send (00-TWxxxxxx), even if it was previously stored and even able to be received from Visma, won't be accepted for further SO creation request
But later (randomly), after few attempts SO will be created.
1) example of received segment from Visma
{"segmentId":2,"valueId":"TW88735","description":"TW88735","active":true,"timeStamp":"AAAAAAbbGcA=","lastModified":"2023-12-08T13:02:36.97"}
2) example of further error upon SO creation while usage of above segment
{"details":[{"code":"1202-SegmentValueNotFound","message":"The value 'TW88735' is not valid for SegmentId 2","parameters":{"property":"orderLines[0].subaccount"}},{"code":"1202-SegmentValueNotFound","message":"The value 'TW88735' is not valid for SegmentId 2","parameters":{"property":"orderLines[1].subaccount"}},{"code":"1202-SegmentValueNotFound","message":"The value 'TW88735' is not valid for SegmentId 2","parameters":{"property":"orderLines[2].subaccount"}},{"code":"1202-SegmentValueNotFound","message":"The value 'TW88735' is not valid for SegmentId 2","parameters":{"property":"orderLines[3].subaccount"}},{"code":"1202-SegmentValueNotFound","message":"The value 'TW88735' is not valid for SegmentId 2","parameters":{"property":"orderLines[4].subaccount"}}],"errors":{"DomainValidation":["The value 'TW88735' is not valid for SegmentId 2","The value 'TW88735' is not valid for SegmentId 2","The value 'TW88735' is not valid for SegmentId 2","The value 'TW88735' is not valid for SegmentId 2","The value 'TW88735' is not valid for SegmentId 2"]},"title":"One or more validation errors occurred.","status":400,"detail":"Refer to the errors property for additional details","instance":"/api/v3/SalesOrders"}
1.) Create segment:
https://integration.visma.net/API/controller/api/v1/dimension/SUBACCOUNT/2
{
"segmentValues": [
{
"operation": "Insert",
"value": "TW88752",
"description": {
"value": "TW88752"
},
"active": {
"value": true
}
}
]
}
Response has HTTP 200, and empty body.
Subaccount has been created:
2.) request for SO
https://salesorder.visma.net/api/v3/SalesOrders
{
"type": "SO",
"status": "Open",
"orderId": "SO88752",
"requestOn": "2023-12-12T12:51:51.000000Z",
"customer": {
"id": "237433",
"order": "TW88752",
"refNo": "Test reference"
},
"print": {
"descriptionOnInvoice": true,
"noteOnInternalDocuments": true,
"noteOnExternalDocuments": true
},
"orderLines": [
{
"inventoryId": "TEXT",
"description": "Order: TW88752 \nFrom: Amsterdam, NL (2023-12-12)\nTo: Berlin, DE (2023-12-12)\nReference: Test reference",
"quantity": 1,
"unitCost": 0,
"unitPrice": 0,
"requestDate": "2023-12-12T12:51:51.000000Z",
"subaccount": {
"1": "00",
"2": "TW88752"
}
},
{
"inventoryId": "ROAD",
"description": "Transport by road\nVehicle: Model1\nChassis number: 9ZPB76\n",
"quantity": 1,
"unitCost": 0,
"unitPrice": 0,
"requestDate": "2023-12-12T12:51:51.000000Z",
"subaccount": {
"1": "00",
"2": "TW88752"
}
},
{
"inventoryId": "TOWING",
"description": "Towing surcharge",
"quantity": 1,
"unitCost": 0,
"unitPrice": 0,
"requestDate": "2023-12-12T12:51:51.000000Z",
"subaccount": {
"1": "00",
"2": "TW88752"
}
},
{
"inventoryId": "TOWING",
"description": "Non rollable surcharge",
"quantity": 1,
"unitCost": 0,
"unitPrice": 0,
"requestDate": "2023-12-12T12:51:51.000000Z",
"subaccount": {
"1": "00",
"2": "TW88752"
}
},
{
"inventoryId": "ROAD",
"description": "Transport by road\nVehicle: Model2\nChassis number: TEST456\n",
"quantity": 1,
"unitCost": 0,
"unitPrice": 0,
"requestDate": "2023-12-12T12:51:51.000000Z",
"subaccount": {
"1": "00",
"2": "TW88752"
}
}
]
}
Response:
{
"details": [
{
"code": "1202-SegmentValueNotFound",
"message": "The value 'TW88752' is not valid for SegmentId 2",
"parameters": {
"property": "orderLines[0].subaccount"
}
},
{
"code": "1202-SegmentValueNotFound",
"message": "The value 'TW88752' is not valid for SegmentId 2",
"parameters": {
"property": "orderLines[1].subaccount"
}
},
{
"code": "1202-SegmentValueNotFound",
"message": "The value 'TW88752' is not valid for SegmentId 2",
"parameters": {
"property": "orderLines[2].subaccount"
}
},
{
"code": "1202-SegmentValueNotFound",
"message": "The value 'TW88752' is not valid for SegmentId 2",
"parameters": {
"property": "orderLines[3].subaccount"
}
},
{
"code": "1202-SegmentValueNotFound",
"message": "The value 'TW88752' is not valid for SegmentId 2",
"parameters": {
"property": "orderLines[4].subaccount"
}
}
],
"errors": {
"DomainValidation": [
"The value 'TW88752' is not valid for SegmentId 2",
"The value 'TW88752' is not valid for SegmentId 2",
"The value 'TW88752' is not valid for SegmentId 2",
"The value 'TW88752' is not valid for SegmentId 2",
"The value 'TW88752' is not valid for SegmentId 2"
]
},
"title": "One or more validation errors occurred.",
"status": 400,
"detail": "Refer to the errors property for additional details",
"instance": "/api/v3/SalesOrders"
}
Unfortunately the proposal does not work :
The value '00-TW88757' is not valid for SegmentId 1, A value for SegmentId '2' is not supplied.
As for second one : settings at the screenshot are equal to what we have - see my screenshot.
If we manually add the segment in Visma GUI and use this in the API request it is working well.
Also the segment that has been created by the API, is accepted by a purchase order and the client invoice.
Hello Johan, could you please test the same request again today and inform us ? We suspect that this is related to the cache, which should be aligned approximately 1 hour after segment/value changes.
Copyright © 2022 Visma.com. All rights reserved.