API error


We are seeing an error from Cetec on a few things with our API and trying to get them worked out.
First is when we receive an order online from a customer who has to pay sales tax.

This is the error the CETC ImportJSON API returned when trying to create order with Tax Amount of 1.40

JSON Parse Error: unexpected end of string while parsing JSON string, at character offset 166 (before “(end of string)”) at lib/Cetec/Reboot/Web/Controller/ImportJSON.pm line 219.
Quote Creation Errors: Can’t use string ("") as a HASH ref while “strict refs” in use at lib/Cetec/Reboot/Web/Controller/ImportJSON.pm line 238.

We are adding the tax to the ‘Tax_Collected’ field available in the endpoint

Also, I have noticed the API documentation no longer has the ‘freight_estimate’ field. Can you confirm that this field is still available in the importJSON endpoint?

Hi @J_Ochs,
Thanks for the questions! We’ll have to have someone from our engineering team take a look, and get back to you about them. We’ll get this over to that team now.

Hi @J_Ochs ,
The error that you’re receiving “JSON Parse Error: unexpected end of string…” means that the JSON you’ve submitted is not formatted properly. Most commonly this is because of a missing comma, or a comma at the end where it doesn’t belong.
I have, in the past used a tool such as this to make sure my JSON was correct to begin with (for me, it wasn’t) : https://jsonformatter.curiousconcept.com/

the key: freight_estimate is still the proper field to use. It is still available, but may have been moved in the docs.

Tax Collected is a flat amount that assumes that you have received monies as part of your sale price to account for that. the proper key would be “tax_collected”. This is currently the best way to account for tax using the API, though generally we would recommend setting up tax authorities & groups and using those in the quote header. The Tax Collected should show in the header as well.

Hope that helps!

Thank you, we seem to be moving forward now.