Unable to add point Code 4010 (Geo location Rest API)

Greetings,
I’m trying to add a gps point using restSharp (compiled for mono-droid / xamarin).

I’m using this code.

var _client = new RestClient("https://api.backendless.com");
var _addLocationRequest = new RestRequest("/v1/geo/points", Method.PUT);

_addLocationRequest.AddHeader("secret-key", _backendSecretKey);
_addLocationRequest.AddHeader("application-id", _backendApplicationId);

_addLocationRequest.AddParameter("lat", latitude);
_addLocationRequest.AddParameter("lon", longitude);
_addLocationRequest.AddParameter("categories", _backendGeoCategoryName);

var _locationResponse = _client.Execute(_addLocationRequest);

but when I do I get the error .- Unable to Add point code:4010
Any help would be greatly appreciated.

oh and congratulations, great platform, keep up the good work,
Geo

Thanks for taking the time to answer Mark.
I’m sure I’m doing something wrong, but I added your suggestions and still don’t get the desired effect.

here’s the full code.

 Console.WriteLine("Please wait...");
            Console.WriteLine("\n");

            var _latitude = "18.44351344032511";
            var _longitude = "-69.93911127576403";

            var _backendApplicationId = "C29B3323-8CF3-2D41-FF2C-8F31A8B78E00";
            var _backendSecretKey = "B99D3B4E-2280-28C8-FF72-ADA650A90200"; //REST SECRET KEY
            var _backendVersion = "v1";
            var _backendGeoCategoryName = "taxistas";
            var _backendApiUrl = "https://api.backendless.com";
            var _backendGeoApiUrl = string.Format("/{0}/geo/points", _backendVersion);
            //var _backendGeoApiUrl = string.Format("/version/geo/points");

            var _client = new RestClient(_backendApiUrl);
            var _addLocationRequest = new RestRequest(_backendGeoApiUrl, Method.PUT);

            _addLocationRequest.AddHeader("secret-key", _backendSecretKey);
            _addLocationRequest.AddHeader("application-id", _backendApplicationId);
            _addLocationRequest.AddHeader("application-type", "REST");
            _addLocationRequest.AddHeader("Content-Length", "0");


            _addLocationRequest.AddParameter("lat", _latitude);
            _addLocationRequest.AddParameter("lon", _longitude);
            _addLocationRequest.AddParameter("categories", _backendGeoCategoryName);

            var _locationResponse = _client.Execute(_addLocationRequest);
            
            Console.WriteLine("\n");
            Console.WriteLine(_locationResponse.Content);
            Console.WriteLine("\n");
            Console.WriteLine("\n");

            Console.WriteLine("Press enter to finish");
            Console.ReadLine();

I added a test visual studio command solution in case you want to look at the code with visual studio.

Again, thanks a lot

rest-test-api-code-and-build.zip (94.75kB)

Hi Geo,

The problem appears to be in RestClient. When you create an instance of RestRequest for the PUT operation:

 var _addLocationRequest = new RestRequest(_backendGeoApiUrl, Method.PUT);

And then add parameters with the AddParameter method, the parameters do not end up in the request URL. As a result, “lat”, “lon” and “categories” parameters are never sent to the server. I verified it with the following code:

var uri = _client.BuildUri( _addLocationRequest ).ToString();

I am not familiar with the RestClient library and not sure how to work around that issue, but there are definitely other ways to make a request.Cheers,Mark

Hi Geo,

A couple of things you should change in your code:

    Add the following header: application-type:REST
    Add content length (in this case it should be 0): Content-Length:0
Here's an example of a CURL request that works for me:

curl -H application-id:MY_APP_ID -H secret-key:MY_SECRET_KEY -H application-type:REST -H Content-Length:0 -X PUT -v ‘http://api.backendless.com/v1/geo/points?lat=0&lon=0&categories=foo

Cheers,Mark