how can we create sales order (with line item and completed status) in minimum API calls?

madhupatelmadhupatel Member Posts: 4

I have made two API calls two to make 1 sales order, But my order is in In Progress status. how can I make it complete status?

Endpoints detail:

can you please guide me what's the best practice to create a sales order(with line item and completed status) with minimum API calls?



  • gregaricangregarican Member Posts: 594 
    edited January 13

    What happens when you include "completed": "true" and "completeTime": "yyyy-MM-ddThh:mm:ss+00:00" (of course set to whatever timestamp is valid) in the API request that creates the sale?

    Per the API documentation ( these appear to be fields that you can define. Although there's a chance the documentation could be off...

  • madhupatelmadhupatel Member Posts: 4
    edited January 14


    In create sale endpoint when I'm passing completed and completeTime field I'm not able to add line item for the sales order beacuase we can't edit completed sale order.So In that case what I need to do?

    Endpoints Details

     /API/Account/{accountID}/Sale.json (for creating a sale)

     /API/Account/{accountID}/Sale/{saleID}/SaleLine.json (for creating a sales line items)


     2)Can we pass line item Details in create sales endpoint with completed and completeTime field?

     if it's possible please provide JSON formate how can we pass it.

  • gregaricangregarican Member Posts: 594 

    The API documentation doesn't provide an example of a one-shot API request for POST'ing a new sale with its accompanying line item(s). I'd suggest trying it to see what the outcome is.

    If that doesn't work, then you are essentially looking at a clumsy multiple step process --- creating the new sale record, assigning line items to the sale record, and then changing the sale status (if possible after the fact). 😣

  • madhupatelmadhupatel Member Posts: 4

    Hey Gregarican,

    Thanks for your suggestion. But I have already tried both solutions and it doesn't work.

    1 case) when I'm trying to create sales with line items it's only created the sale and not added my line items.

    2 case) Then I created a sales order and then I added my line item to sale after that I'm trying to change the status of the sale it's giving me the below error. Please let me know how can I solve this issue.


      "httpCode": "400",

      "httpMessage": "Bad Request",

      "message": "Cannot complete an out of balance sale. Payments are insufficient.",

      "errorClass": "OutOfBalanceError",

      "saleID": "14",

      "balance": "10"

  • gregaricangregarican Member Posts: 594 

    Sorry you're still running into trouble with this. As for the insufficient payments response you're getting, do these transactions involve non-taxable items or discounts? There are a few threads on here involving quirks with those use cases. Also, can you post a sanitized version of your API requests that are failing with this error?

Sign In or Register to comment.