[SOLVED] How can i send GPS lat & long to ubidots C# API

Hi There , how can I send the GPS coordinates to the Ubidots C# API Client?

Thanks

Dear @paulo,

To send coordinates using the Ubidots C# you have to create a directory containing the coordinates desired. As an example, reference to the code below. Please, don’t forget assign you Ubidots API Key where is indicated in the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ubidots;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            ApiClient Api = new ApiClient("xxxxxxxxxxxxxxxxxxxxxxxx");
            DataSource NewDataSource = Api.CreateDataSource("device-test-community");
            Variable NewVariable = NewDataSource.CreateVariable("position");
            Dictionary<string, object> context = new Dictionary<string, object>()
            {
                { "lat", 37.773972 },
                { "lng", -122.431297 }
            };
            NewVariable.SaveValue(1, context );
        }
    }
}

After testing it, the result:

I hope this would help you!

All the best,
Maria C.

Hi Maria, Thanks for the reply… now i’m able to publish the coords in Ubidots

Although I can’t see it in the dashboards:

Thanks

Dear user,

The variable which contains the coordinates should be called “position”, “coordinates”, or “gps” with any of those labels the device will be automatically located in the map widget by the Ubidots backend.

For more information please see, Ubidots REST API Reference.

All the best,
Maria C.