Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forward URL #1811

Open
mm108 opened this issue Mar 22, 2016 · 23 comments
Open

forward URL #1811

mm108 opened this issue Mar 22, 2016 · 23 comments

Comments

@mm108
Copy link

mm108 commented Mar 22, 2016

I have an online db into which data case be inserted using the following ajax call. Can I change the transform URL to do the same? Btw I also need the IMEI to be part of the position

How do I get the IMEI to also be a part of gprmc data. I believe the uniqueId is the IMEI? Can I just move the things in bracket in a different way so as to achieve the url format shown in ajax call?

<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://example.com:8080/gprmc/Data?id={uniqueId}&amp;code=0x0000&amp;gprmc={gprmc}</entry>
$.ajax( { url: "https://api.domain.com/database/dbname/my-coll?apiKey=myAPIKey",
          data: JSON.stringify( { "x" : 1 } ),
          type: "POST",
          contentType: "application/json" } );

Thanks for the excellent response time & support
M.M

@tananaev
Copy link
Member

Yes, uniqueId is IMEI (if device uses IMEI number as an id). Also, you don't have to use gprmc if you don't want to parse it. You can access to location attributes directly:

https://github.com/tananaev/traccar/blob/master/src/org/traccar/WebDataHandler.java#L99

@mm108
Copy link
Author

mm108 commented Mar 22, 2016

You mentioned that "if device uses IMEI number as an id" ... do you mean there are devices where the ID is not IMEI? In that case when you add a new device, what is to be used for Identifier? That may depend on the device I guess but can you name any so that I can look it up to understand it better. Thanks

@tananaev
Copy link
Member

For example most devices with TK103 protocol use 12-digit identifier instead of IMEI.

@mm108
Copy link
Author

mm108 commented Mar 22, 2016

oh alight, thanks :-)

@mm108
Copy link
Author

mm108 commented Mar 22, 2016

<entry key='forward.url'>http://example.com:8080/gprmc/Data?id={uniqueId}&amp;code=0x0000&amp;gprmc={gprmc}</entry>

Btw does the &amp;code=0x0000&amp; in the forward url example mean something?

@tananaev
Copy link
Member

It's a status code for OpenGTS.

@mm108
Copy link
Author

mm108 commented Mar 22, 2016

ok thanks. and the uniqueId will "either" be the IMEI or the 12-digit identifier depending upon the device type I guess

@tananaev
Copy link
Member

Yes. Some other types of devices can use other identifiers as well.

@mm108
Copy link
Author

mm108 commented Mar 22, 2016

cool thanks 👍

@mm108
Copy link
Author

mm108 commented Mar 22, 2016

So any suggestion for "transforming" the forward url? Or do you think it would be best if I call another page on the web server, then manipulate the URL the way I want and then post it to the online db using ajax? Or could there be a better way? Thanks

@tananaev
Copy link
Member

Well, I guess you need to write some code either way. You can just modify Traccar to send in the format that you need.

@mm108
Copy link
Author

mm108 commented Mar 22, 2016

okay, so if I just need to change the forward url to send the parameters in a json string, either with IMEI or the Identifier (whichever is available), which part of the code do I modify? Thanks

@tananaev
Copy link
Member

I already provided a link above.

@mm108
Copy link
Author

mm108 commented Mar 22, 2016

right thanks but I only want the forward url format to be changed rest remaining the same

@tananaev
Copy link
Member

Is there something wrong with the link I provided?

@mm108
Copy link
Author

mm108 commented Mar 22, 2016

well not really. I'll figure that out. Thanks

@mm108
Copy link
Author

mm108 commented Mar 22, 2016

btw forward.url is executed by a GET or POST request? Thanks

@tananaev
Copy link
Member

By default it's GET as far as I remember.

@mm108
Copy link
Author

mm108 commented Mar 23, 2016

@kani-rifluxyss
Copy link

I was wondering why the positions not coming through GET or POST methods. We had specified only the URL for the script, did not include the parameters! :| Helped by the question details by @m-menon
Thanks a lot.

@tananaev and the great devs at Traccar, it may help new users if you could add a note about the URL parameters in the document for "forward.url"

https://www.traccar.org/configuration-file/

Thanks again for the wonderful project!

@tananaev
Copy link
Member

tananaev commented Nov 4, 2016

Updated documentation with some more info, thanks.

@kani-rifluxyss
Copy link

Awesome!!!

@mm108
Copy link
Author

mm108 commented Nov 4, 2016

Amazing support as always 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants