My Products
Help
Anonymous
Not applicable

customerinvoice v2 API response: "value 0 - 0 is not valid for this type of request."

by Anonymous

In order to minimize toil in our organization I am developing an integration that will consumes contract data from HubSpot and injects it as invoices into Visma.net Financials. I have successfully opened an ISV account, and created a debtor and invoice through the GUI. My next step is to attempt to create an invoice through the API, I selected the customerinvoice v2 POST endpoint for this purpose.

 

Request

Headers:

Authorization: Bearer ....

Postman-Token: <calculated when request is sent>

Content-Type: application/json

Content-Length: <calculated when request is sent>

Host: <calculated when request is sent>

User-Agent: PostmanRuntime/7.26.5

Accept: */*

Accept-Encoding: gzip, deflate, br

Connection: keep-alive

ipp-company-id: ...

ipp-application-type: Visma.net Financials

 

Body

{
"cashDiscountDate": {
"value": "2020-10-27T00:00:00.000Z"
},
"creditTermsId": {
"value": "30"
},
"customerNumber": {
"value": "20000"
},
"documentDate": {
"value": "2020-10-27T00:00:00.000Z"
},
"documentDueDate": {
"value": "2020-11-26T00:00:00.000Z"
},
"financialPeriod": {
"value": "10-2020"
},
"invoiceLines": [
{
"accountNumber": {
"value": "8100"
},
"quantity": {
"value": 100
},
"subaccount": [
{
"segmentId": 2,
"segmentValue": "0"
}
],
"unitPriceInCurrency": {
"value": 5
},
"vatCodeId": {
"value": "1"
}
}
]
}

 

Expectation

HTTP status: 201 Created

 

Response

HTTP status: 400 Bad Request

Body

{"message":"VismaId: 09a72d7e-4c55-4680-99b0-26723da8334c. Error creating document. Operation parameter: value 0 - 0 is not valid for this type of request."}

 

I tried adding, changing, removing different elements in my request body but I haven't figured out what the "value 0 - 0" refers to. Does anyone here know what this message means?

 

 

2 REPLIES 2
Accepted solution
Magnus Johnsen
VISMA

by Magnus Johnsen

Hi,

 

From what I can see, to start with you need to specify an operation for the invoice line:

 "operation": "Insert" - To create a new line

 

There should be an inventoryNumber, or if the line does not have an item, at least a description of the line.

"inventoryNumber": {
        "value": "string"
      },
      "description": {
        "value": "string"
      },

Please also have a look in the UI what subaccount you want to use, the value you have provided would translate that the second segment in the subaccount should be "0". E.g xx-0

Subaccount numbers are built up in the segments that you have specified in the ui(ScreenId=GL203000) as such:

 "subaccount": [
        {
          "segmentId": 1,
          "segmentValue": "1stSegment"
        },
{
          "segmentId": 2,
          "segmentValue": "2segment"
        },
{
          "segmentId": 3,
          "segmentValue": "3Segment"
        }
      ],

 

Please have a look at this article that contains some basic usage of Customer Ledger endpoints:

How to use Visma.Net API Endpoints: Customer Ledger 

Anonymous
Not applicable

by Anonymous

Thank you, Magnus!

 

Yesterday I was relying on the GUI to find the required properties of an invoice. Sadly, the operation is not presented in a way to makes this clear. (It would be lovely if the Swagger mentioned which parameters are required instead.)

 

I am able to create an invoice without specifying inventoryNumber or description (see my new request body below). The sub account definition in my request body was invalid, but I corrected it based on the response I got when fetching an existing invoice (which was created through the GUI).

 

Request body

{
"cashDiscountDate": {
"value": "2020-10-27T00:00:00.000Z"
},
"creditTermsId": {
"value": "30"
},
"customerNumber": {
"value": "20000"
},
"documentDate": {
"value": "2020-10-27T00:00:00.000Z"
},
"documentDueDate": {
"value": "2020-11-26T00:00:00.000Z"
},
"financialPeriod": {
"value": "202010"
},
"invoiceLines": [
{
"accountNumber": {
"value": "8100"
},
"operation": "Insert",
"quantity": {
"value": 100
},
"subaccount": [
{
"segmentId": 1,
"segmentValue": "0"
}
],
"unitPriceInCurrency": {
"value": 5
},
"vatCodeId": {
"value": "1"
}
}
]
}