My Products
Help
Anonymous
Not applicable

Trying to add a new sales order in SalesOrder

by Anonymous (Updated ‎17-02-2021 14:15 by Yıldırım VISMA )

Hello everyone, 

 

First of all I'm new to the Visma.Net API. I'm trying to add a new sales order in the API, but whenever I'm trying to pass the JSON model it gives me an error saying "Order type must be specified". The thing is that my Order type is specified. I copied the same model from the GET request for SO Order.  I've already authorised myself and added the company-id as the header before doing these requests. This is the model I'm trying to pass in /controller/api/v1/salesorder;

 

{
  "project": 0,
  "soBillingContact": {
    "overrideContact": false,
    "contactId": 50443,
    "name": "FygiAPP"
  },
  "soBillingAddress": {
    "overrideAddress": false,
    "addressId": 51192,
    "postalCode": "1658",
    "city": "TORP",
    "country": {
      "id": "NO",
      "name": "NORGE"
    },
    "county": {
      "id": "0106",
      "name": "FREDRIKSTAD"
    }
  },
  "customerVATZone": {
    "id": "01",
    "description": "Salg innenlands, avgiftspliktig",
    "defaultVatCategory": "3"
  },
  "terms": {
    "id": "14",
    "description": "14 dager netto"
  },
  "salesPerson": {},
  "owner": {},
  "soShippingContact": {
    "overrideContact": false,
    "contactId": 50443,
    "name": "FygiAPP"
  },
  "soShippingAddress": {
    "overrideAddress": false,
    "addressId": 51192,
    "postalCode": "1658",
    "city": "TORP",
    "country": {
      "id": "NO",
      "name": "NORGE"
    },
    "county": {
      "id": "0106",
      "name": "FREDRIKSTAD"
    }
  },
  "schedShipment": "2021-02-17T00:00:00",
  "shipSeparately": false,
  "shipComplete": "BackOrderAllowed",
  "cancelBy": "2021-02-16T00:00:00",
  "canceled": false,
  "preferredWarehouse": {},
  "shipVia": {},
  "fobPoint": {},
  "priority": 0,
  "shippingTerms": {},
  "shippingZone": {},
  "residentialDelivery": false,
  "saturdayDelivery": false,
  "insurance": false,
  "transactionType": {
    "id": 0,
    "description": "Ingen (unntatt)"
  },
  "paymentMethod": {
    "id": "1",
    "description": "Innlandsbetalinger"
  },
  "cashAccount": "1910",
  "lines": [],
  "shipments": [],
  "orderType": "SO",
  "orderNo": "000004",
  "status": "Hold",
  "hold": true,
  "date": "2021-02-16T00:00:00",
  "requestOn": "2021-02-17T00:00:00",
  "customer": {
    "internalId": 21956,
    "number": "10004",
    "name": "FygiAPP"
  },
  "location": {
    "id": "HOVED",
    "name": "Hovedlokasjon"
  },
  "currency": "NOK",
  "orderTotal": 0,
  "orderTotalInBaseCurrency": 0,
  "vatTaxableTotal": 0,
  "vatTaxableTotalInBaseCurrency": 0,
  "vatExemptTotal": 0,
  "vatExemptTotalInBaseCurrency": 0,
  "taxTotal": 0,
  "taxTotalInBaseCurrency": 0,
  "exchangeRate": 1,
  "discountTotal": 0,
  "discountTotalInBaseCurrency": 0,
  "lastModifiedDateTime": "2021-02-16T16:02:56.2",
  "branchNumber": {
    "number": "1",
    "name": "Fygi Test"
  },
  "attachments": []
}

 As you can see my order type is "SO" in the model, but it still wont let me add this sales order. What am I doing wrong?

6 REPLIES 6
Accepted solution
Yıldırım
VISMA

by Yıldırım (Updated ‎17-02-2021 14:15 by Yıldırım VISMA )

Hello Suzdar, 

GET:SalesOrderDto data model is for reading the data from Sales Order Endpoint that is corresponding with Sales Order Module (ScreenId=SO301000) in the Financials ERP UI.

For POST operations and its DTO, you should look at POST : saleOrderUpdateDto 
SO.png

We'd recommend you first checking the Sales Order document in the Financials ERP UI to determine what field you'd like to interact via the API then you can build your API payload based on transaction need.

You should only include the fields in the JSON that you'd like to set a value otherwise please exclude those fields from your payload.

Here is an example POST Sales Order JSON: 

 

{
    "orderType": {
        "value": "SO"
    },
    "hold": {
        "value": false
    },
    "date": {
        "value": "2020-02-17"
    },
    "customerRefNo": {
        "value": "AAA#6111"
    },
    "customer": {
        "value": "10023"
    },
    "currency": {
        "value": "NOK"
    },
   "lines": [
        {
            "operation": "Insert",
            "lineNbr": {
                "value": 1
            },
            "inventoryId": {
                "value": "5"
            },
            "warehouse": {
                "value": "1"
            },
            "uom": {
                "value": "STK"
            },
            "quantity": {
                "value": 1
            },
            "unitPrice": {
                "value": 111.2
            },
            "lineDescription": {
                "value": "TEST SO"
            }
        }
    ]
}

 




PetterElgheim
CONTRIBUTOR *

by PetterElgheim

Hi,


I'm using Visma.net ERP Service API. According to the documentation https://integration.visma.net/API-index I should be able to create a salesOrder, but I get response 403 with message: "Scope requirement not met". I have enabled everything, so I don understand why I don't have permission. 

 

Can you or anyone help?

 

Anonymous
Not applicable

by Anonymous

Hi Yildirim, 

 

Thank you for using your time on this issue. 

I'm just wondering why the example value model is so different in the documentation compared to yours? I tested it and it works, I'm just a bit confused to why it worked 🙂 

by Yıldırım (Updated ‎17-02-2021 15:05 by Yıldırım VISMA )

Hello Suzdar, 

 

The Example Model (POST) in the swagger represents whole available fields exposed via the API - SalesOrder Endpoint with empty values.

Example we've shared above is a most frequently used fields in daily operation. For sure more fields can be added as we mentioned before, checking Financials ERP UI and determining your payload based on what you're aiming to achieve with the transaction. 🙂

Anonymous
Not applicable

by Anonymous

I see! So I only need to look at the UI for the required fields in order to do the right POST requests? 

 

Another thing i stumbled across is when I'm trying to pass in the order type "CS" instead of "SO". I get this error message: "Error: Inserting 'Sales order' record raised at least one error. Please review the errors.\r\nDid not find a financial period that matches the selected Invoice date.\r\nError: 'Payment ref.' cannot be empty.\r\n" 

 

Is it because the sales order is missing a payment card ? or am I missing something else? 

 

by Yıldırım (Updated ‎17-02-2021 16:24 by Yıldırım VISMA )

To be able to build an integration with API , you should be able to understand the fundamentals of the Visma.net Financials ERP and business flow logic.

As those details have been included in the API Certification & Training that you've completed, please also review the following article: API incidents - Troubleshooting and reporting

The most efficient way of analysing the root cause of the errors returned via the API is trying to perform the same operation with the same values in the Financials ERP UI. In this way ERP system can prompt the errors in the interface and highlights them for you. So that configurations can be adjusted. 

Based on the returned error message,

  • Error:Did not find a financial period that matches the selected Invoice date.
    This is about your company setup. You (Company ERP responsible) should set up financial periods that is corresponding with your document date. 

    In the browser URL: ScreenId=GL201000
    2021-02-17 16_17_03-Window.png

  • Error: 'Payment ref.' cannot be empty 
    Based on ERP Company Payment Method settings.  (ScreenId=CA204000)

      "paymentRef": {
        "value": "string"
      },

     

If you need help regarding Financials ERP / Configuration / Company setup you can contact partner service from your market to reach out ERP Support.

Please feel free to inform us if you need any further information regarding the API.
Thanks.