Hello everyone, I'm currently facing an issue wit...
# suitetalkapi
m
Hello everyone, I'm currently facing an issue with creating a standalone invoice that includes a discount item via the REST API. The discount percentage needs to vary order by order, but I'm encountering difficulties specifying a percentage discount (-50%) in the API requests. Using the User Interface (as shown in the attached image), I can apply this discount without any issues. However, attempts to express the rate of -50% in JSON format have been unsuccessful. Without quotes, the JSON is invalid; with quotes, the API returns an error stating it is "Unable to parse value '-50.00%' (String) from the Number field (rate)." Here’s the part of the payload where I specify the 50% discount:
Copy code
{
  "rate": "-50%",
  "price": {
    "id": "-1"
  },
  "item": {
    "id": "7482"
  },
  "memo": "Test Discount",
  "quantity": 1,
  "location": {
    "id": "104"
  },
  "class": {
    "id": "40"
  }
}
Notably, fixed price discounts and discounts inheriting prices from items are functioning correctly. The challenge specifically arises with percentage-based rates. Could anyone suggest a workaround or solution to this problem? Thank you in advance. Best regards, Manuel
b
The error seems to indicate a formatting problem. Have you tried to pass the value as a number, such as -0.50?
m
Yes but if I omit % it is considered as fixed value and not percent value.