Live tracking on own Webservices

marcw shared this question 2 months ago
Answered

Hi,I developed my own server for device tracking. I want also use Locus Map pro with live-tracking.

So far my webservice is working via Postman but I'n not able to insert data from my Locus Map Pro.

Is there a documentation about this?

My webservice is accepting Post requests in Json-Format.

Thanks for any help.

Marc

Best Answer
photo

Hello,

please refer to this manual page.

Custom live tracking will not produce JSON request when using POST as far as I know. It should produce a request with content type of application/x-www-form-urlencoded with the query string encoded in the body. If you are using your custom server solution, maybe create a new endpoint consuming the data in the given format and after parsing just forward it to your server logic the same way as your usual JSON payload?

Best regards

Milan

Comments (2)

photo
1

Hello,

please refer to this manual page.

Custom live tracking will not produce JSON request when using POST as far as I know. It should produce a request with content type of application/x-www-form-urlencoded with the query string encoded in the body. If you are using your custom server solution, maybe create a new endpoint consuming the data in the given format and after parsing just forward it to your server logic the same way as your usual JSON payload?

Best regards

Milan

photo
1

Hi Milan,

 

Your are right the Post is "application/x-www-form-urlencoded " It's working, but I need to do some mapping to save all my fields.


Thank you

Marc

[HttpPost]
        [Route("api/Tracking")]
        [Consumes("application/x-www-form-urlencoded")]
        public async Task<ActionResult<Tracking>> PostAsync([FromForm] Tracking wayPoint)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    wayPoint.UserId = _context.Users.FirstOrDefault().Id;
                    
                    _context.Add(wayPoint);
                    await _context.SaveChangesAsync();
                    return Ok();
                }
                catch (Exception ex)
                {
                    return BadRequest(ex.Message);
                }
            }
            return BadRequest(ModelState);
        }

photo