CGrateS – SERVER_ERROR: unexpected end of JSON input

I started seeing this error the other day when running CDRsv1.GetCDRs on the CGrateS API:

SERVER_ERROR: unexpected end of JSON input

It seemed related to certain CDRs in the cdrs table of StoreDB.

After some digging, I found the stupid simple problem:

I’d written too much data to extra_fields, leading MySQL to cut off the data mid way through, meaning it couldn’t be reconstructed as JSON by CGrateS again.

Like the rounding issue I had, this wasn’t an issue with CGrateS but with MySQL.

Quick fix:

sudo mysql cgrates -e "ALTER TABLE cdrs MODIFY extra_fields LONGTEXT;"

And new fields can exceed this length without being cut off.

One thought on “CGrateS – SERVER_ERROR: unexpected end of JSON input

  1. Hi Nick,

    Thank you for the incredibly helpful tutorials on your blog—they’ve been a fantastic resource!

    I have a question about configuring CDR extra_fields:
    How can I populate this column with specific variables from FreeSWITCH, such as caller_id_number, during a call?

    For example: When a call is initiated, can caller_id_number be mapped to extra_fields in the CDR record?

    Are there specific parameters or configurations required in FreeSWITCH or CGRateS to achieve this?

    Any guidance or examples you could share would be greatly appreciated.

    Many Thanks before.

Leave a Reply

Your email address will not be published. Required fields are marked *