I am trying to save purchase invoice using api2. But Unit price is not saving

Hi I am using api2 for the manager.io. Now I am trying to post the purchase invoice from my system to manager.io. Now the issue is that everything is working fine except the unit price in the lines array. It is not saving with the all other details. Can anyone help what i am doing wrong in this json body. I have also place the array i am doing for posting. I have change UnitPrice to Amount, Total as well to check. But nothing is working. Please anyone can help me on this issue. Thank you.
{
“Supplier”: “xxxx”,
“Reference”: “INV-001”,
“IssueDate”: “2024-07-15”,
“Lines”: [
{
“Item”: “xxxxx”,
“Qty”: 2,
“UnitPrice”: 50.00,
}
]

PurchaseUnitPrice for Purchase and Payment

{
  "IssueDate": "2024-05-30",
  "Reference": "3",
  "Supplier": "28fe66e1-e658-4a65-be94-6e6ad721d2f9",
  "Lines": [
    {
      "Item": "6fe116be-331e-4b1e-9436-aa584d9c5634",
      "LineDescription": "Item with 15% Vat",
      "Qty": 1,
      "PurchaseUnitPrice": 500,
      "TaxCode": "1731afd8-40df-484c-8335-81a1451ab8f8"
    },
    {
      "Account": "4a0e8917-fee2-4033-9161-48dd513fdb73",
      "FixedAsset": "b2ad6e05-9a81-4ffa-b4cd-3b423b4acdce",
      "PurchaseUnitPrice": 10000
    }
  ],
}

look at https://{{subdomain}}.manager.io/api
we can get json structure from there…

Nowadays if you added a reference / code you no longer have to use the UUIDs for Supplier, Item, TaxCode, Account, and FixedAsset as in example script. It is also important that the IssueDate format is the one you setup for Manager to use.

The code can be used in Batch updates, for Api/Api2 you must still use GUID/UUID.

{
  "IssueDate": "2024-07-03",
  "Reference": "5",
  "Supplier": "SPL01",
  "Lines": [
    {
      "Item": "ITM01",
      "Qty": 20,
      "PurchaseUnitPrice": 2000
    }
  ],
  "AlsoActsAsGoodsReceipt": true
}

Api Response :

{
  "error": "Newtonsoft.Json.JsonSerializationException: Error converting value \"SPL01\" to type 'System.Nullable`1[System.Guid]'. Path 'Supplier', line 4, position 21.\n .....
}
1 Like

Your solution work. Thank you so much.