[SOLVED] GPS data with the FONA

One of our users just posted this in our support portal, we though you guys could have some answers in the community:

Hi,
i am trying to send data with Fona, everything works fine so far, but if i want to upload GPS-data via “context” i also get a “BAD Request” as a response. The same code with curl works fine.

In my Fona-Code (which is based on the tutorial on your page) i exchanged the “value” statement which used to be
var = “{“value”:” + value + “}”;
with
var = “{“value”: 10, “context”: {“lat”:” + String(latval2) + “,“lng”:” + String(lonval2) + “}}”;

Any idea what is goirn wrong?
thx s

S,
I have this working on a couple devices now. Here are some sources of the “BAD Request” error:

  1. If your Long has a leading zero (so 076 will not work but 76 will).
  2. How are you calculating the length which is required in the sketch.
    These are the two most common mistakes I make.

If you are still having problems, can you show exactly what you are sending (using a terminal print) and I would be glad to take a look.

Chip

1 Like

@chipmc thanks!

Problem fixed - actually the API doesn’t seem to accept (perhaps it’s also a general json thing) leading zeros! The location where i live has 06.91 as longitude. If i post this to your servers i gat the “bad request”. If i delete the zero everything works fine…
Thank you nevertheless!
Stephan