Simple API Call Error
I'm attempting to add customers using API instead of importing from Excel since Excel file does not contain loyalty points; however, I've ran into some abnormal behavior.
I used https://phppointofsale.com/api.php#/ with POST to test adding Customer.
The request body is:
{
"first_name": "Ben",
"last_name": "Franklin",
"points": 247,
"disable_loyalty": false,
"location_id": 1,
}
Curl:
curl -X POST "https://demo.phppointofsale.com/index.php/api/v1/customers" -H "accept: application/json" -H "x-api-key: 484kowo0s00k4css8k0wk0oggogcw0wcs4ws0048" -H "Content-Type: application/json" -d "{ \"first_name\": \"Ben\", \"last_name\": \"Franklin\", \"points\": 247, \"disable_loyalty\": false, \"location_id\": 1,}"
Code is showing 200; however, the response body didn't "post" the customer's name or other settings.
{
"person_id": 36,
"first_name": "",
"last_name": "",
"email": "",
"phone_number": "",
"address_1": "",
"address_2": "",
"city": "",
"state": "",
"zip": "",
"country": "",
"comments": "",
"internal_notes": "",
"custom_fields": [],
"company_name": "",
"tier_id": 0,
"account_number": null,
"taxable": true,
"tax_certificate": "",
"override_default_tax": false,
"tax_class_id": 0,
"balance": 0,
"credit_limit": 0,
"disable_loyalty": false,
"points": 0,
"amount_to_spend_for_next_point": 0,
"remaining_sales_before_discount": 0,
"image_url": "",
"created_at": "02/28/2020 03:39 am",
"location_id": null
}
I do see the Person ID #36 in the demo POS with empty First and Last name. I also tried updating an existing customer but it didn't apply the changes made from the request body. What am I doing wrong? How do I get this to work?
Thanks.
Comments
2 comments
Looks like your JSON isn’t valid. You have an extra comma after location_id
Thanks Chris. Good catch.
Please sign in to leave a comment.