Create new order doesnt work with v1 api

Hello Im using this method to create a new order:

https://developer.keap.com/docs/rest/#tag/E-Commerce/operation/createOrderUsingPOST

Request body is the following:

{“contact_id”:15064,“order_type”:“Online”,“order_date”:“2019-08-24T14:15:22Z”,“order_items”:[{“price”:“10.0”,“product_id”:156,“quantity”:1}],“order_title”:“Best order”}

Response:

{“message”:“Input could not be converted to a valid request”}

I dont understand whats wrong

I copied your JSON, and tested it in a validator, and it came back w/ errors regarding the double quotes.

  • Replaced incorrect quotes.
  • Info: Inserted missing quotes.

If I use your JSON, I get the same error. Try the JSON below w/ the corrected quotes and see if that fixes your issue.

{
   "contact_id":15064,
   "order_type":"Online",
   "order_date":"2019-08-24T14:15:22Z",
   "order_items":[
      {
         "price":"10.0",
         "product_id":156,
         "quantity":1
      }
   ],
   "order_title":"Best order"
}

Hello thanks for answer, its a case these double quotes are not correct in my editor they are perfectly fine.

Also I use Kiota, as api framework that has been generated by the respective openapi specs.
There must be something in the data structure thats missing, in fact It works perfectly fine to query the exsiting orders or to modify or delete one.

The main problem is the creation of a new order.

Anybody?

Cristy,

I was unable to reproduce that error. When supplying a contact and product id that are valid in my sandbox:
POST:

{
   "contact_id":385,
   "order_type":"Online",
   "order_date":"2019-08-24T14:15:22Z",
   "order_items":[
      { 
         "price": "10.0",
         "product_id":1,
         "quantity":1
      }
   ],
   "order_title":"Order Title"
}

Response:

{
    "id": 17,
    "title": "Order Title",
    "status": "DRAFT",
    "total": 10.0,
    "contact": {
        "id": 385,
        "email": "email@example.com",
        "first_name": "",
        "last_name": "",
        "company_name": "",
        "job_title": null
    },
    "notes": null,
    "terms": null,
    "creation_date": "2024-07-12T17:39:24.000Z",
    "modification_date": null,
    "order_date": "2019-08-24T14:15:22.000Z",
    "lead_affiliate_id": 0,
    "sales_affiliate_id": 0,
    "total_due": 10.0,
    "total_paid": 0.0,
    "shipping_information": {
        "line1": null,
        "line2": null,
        "locality": null,
        "region": null,
        "company": null,
        "phone": null,
        "zip_code": null,
        "zip_four": null,
        "country_code": null,
        "first_name": null,
        "middle_name": null,
        "last_name": null,
        "is_invoice_to_company": false
    },
    "refund_total": 0.0,
    "order_items": [
        {
            "id": 15,
            "name": "Wand",
            "description": " ",
            "type": "Product",
            "notes": null,
            "quantity": 1,
            "cost": 0.0,
            "price": 10.0,
            "discount": null,
            "product": {
                "id": 1,
                "sku": null,
                "url": null,
                "status": 0,
                "product_name": "Wand",
                "product_desc": "",
                "product_price": null,
                "product_short_desc": null,
                "subscription_only": false,
                "product_options": [],
                "subscription_plans": []
            },
            "specialId": 0,
            "specialAmount": null,
            "specialPctOrAmt": 0,
            "orderItemTaxes": null,
            "recurringBilling": false,
            "frequency": 0,
            "billingCycle": 0,
            "numberOfPayments": 0,
            "jobRecurringId": 0,
            "recurringStartDate": null,
            "recurringNextBillDate": null,
            "recurringEndDate": null,
            "recurringCyclesCompleted": 0,
            "recurringInactive": false
        }
    ],
    "payment_plan": null,
    "order_discount": null,
    "allow_payment": null,
    "allow_paypal": null,
    "tax_summary_items": null,
    "invoice_number": 0
}

It would appear that Kiota is not providing a properly formatted JSON string to the endpoint. (I had never heard of Kiota until this post.)

The only way I was able to replicate the issue was by using the invalid double quotes. When using the straight double quotes “” it worked fine. When using the slanted or curly “”, I could replicate the same error.

When I just passed curly braces as the payload, I got back a valid error message that I was missing the contact id.


thanks for the information, I will make sure the serializer works properly for the library