Backendless Support
 
In Progress

Storing integer fields in 4.0 through REST API

I was almost ready to release my new application using Backendless through the REST API to store data when the 4.0 release was announced.

As advised, I switched over to the newer version but now data is not stored correctly in any integer field - the ascii string is not being converted to an integer before storing it in the database.

For example sending "1" results in 49 being stored, "2" results in 50, "3" in 51 - this is pure ascii.

Sending "10" results in 12592 being stored, "20" goes to 12848, "30" goes to 13104 - this is ascii( 1st digit ) * 0x10 + ascii( 2nd digit ).

Similarly, sending "100" results in 3223600 and "200" results in 3289136 - this is ascii( 1st digit ) * 0x100 + ascii( 2nd digit ) * 0x10 + ascii( 3rd digit ).

Leave a Comment

Comments (4)

photo
1

Hi Denver,

As long a type of column is "INT" you should send numeric value, not a string.

I mean the inserting to a column with type "INT" will work correctly if you put 1 instead "1", 2 instead "2" etc.

Regards Ilya

photo
1

I am using it through the REST API so everything is a string in the JSON - this worked correctly on version 3.x and I only had to make minor changes for the different URL structure - I did not change anything in the JSON packaging. Why has it changed the results?

photo
1

I understood your problem and we will investigate the question of a backward compatibility of this behavior with our team (internal ticket BKNDLSS-15303).

But still, I strongly recommend you to adhere to type matches. This is valid JSON

  1. {
  2. "column_name": 1
  3. }

as well as this

  1. {
  2. "column_name": "1"
  3. }

Regards Ilya

photo
1

Now I understand. My JSON was technically correct but not the best. That fixes my problem. Thank you.