OpenStreetMap Forum

The Free Wiki World Map

You are not logged in.

#1 2010-09-18 13:46:01

Uploading GPX File via API

hi,

I am trying to upload a GPX file to the public dev server via the API. Unfortunately I am only getting as response a 500 error code. I sniffed the network traffic. Maybe someone can see the error reason or can give me a hint.

Regards

Michael


+++++++++start of data ++++++++++++++++++++++++++++++++++++++++++++++++++++


POST /api/0.6/gpx/create HTTP/1.1
Authorization: Basic xxxxx
Content-Type: multipart/form-data; boundary=----------------------------d10f7aa230e8
User-Agent: Free User Agent
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Host: api06.dev.openstreetmap.org
Content-Length: 7865
Connection: Close

------------------------------d10f7aa230e8
Content-Disposition: form-data; name="file"; filename="test.gpx"
Content-Type: application/octet-stream

<?xml version="1.0" encoding="utf-8"?>
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.topografix.com/GPX/1/1">
  <trk>
    <name>test</name>
    <trkseg>
      <trkpt lat="52.5633193" lon="9.7764445">
        <ele>37.1480713</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5632175" lon="9.7764723">
        <ele>36.6674805</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5624481" lon="9.7765344">
        <ele>37.6286621</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5616805" lon="9.776587">
        <ele>38.109375</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5609024" lon="9.7766767">
        <ele>39.0706787</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.560524" lon="9.7767229">
        <ele>39.0706787</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5596919" lon="9.7766512">
        <ele>39.0706787</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5593889" lon="9.7765394">
        <ele>38.5900879</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5591118" lon="9.7763639">
        <ele>40.5128174</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5586233" lon="9.7757709">
        <ele>40.5128174</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5582964" lon="9.77511">
        <ele>41.9547119</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5580691" lon="9.7747448">
        <ele>41.9547119</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5577638" lon="9.7740512">
        <ele>42.9160156</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5576942" lon="9.7739917">
        <ele>42.4354248</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5413062" lon="9.7868901">
        <ele>41.473999</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5411701" lon="9.7869086">
        <ele>40.9934082</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5413798" lon="9.7887334">
        <ele>38.5900879</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5414412" lon="9.7898591">
        <ele>38.109375</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5415129" lon="9.790873">
        <ele>37.6286621</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5415298" lon="9.7913343">
        <ele>38.109375</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5415294" lon="9.7913648">
        <ele>38.109375</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.531233" lon="9.7662632">
        <ele>40.9934082</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5307834" lon="9.7672886">
        <ele>41.473999</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5307512" lon="9.7675266">
        <ele>42.4354248</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5306283" lon="9.7686465">
        <ele>44.3580322</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5304606" lon="9.7697333">
        <ele>42.9160156</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5302052" lon="9.770987">
        <ele>42.4354248</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5290465" lon="9.7734976">
        <ele>41.9547119</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5286214" lon="9.7730684">
        <ele>40.5128174</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5282203" lon="9.7726276">
        <ele>40.0321045</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5278139" lon="9.7721747">
        <ele>40.5128174</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5273541" lon="9.7716719">
        <ele>40.0321045</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5267106" lon="9.7709699">
        <ele>41.473999</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5263854" lon="9.7706346">
        <ele>41.9547119</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5259749" lon="9.7701861">
        <ele>40.5128174</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5255384" lon="9.7697075">
        <ele>41.9547119</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5252946" lon="9.7694415">
        <ele>42.4354248</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5250435" lon="9.7691663">
        <ele>42.4354248</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5247821" lon="9.7688634">
        <ele>41.9547119</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5245337" lon="9.7687154">
        <ele>41.9547119</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5243628" lon="9.7686988">
        <ele>41.9547119</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5239596" lon="9.7686911">
        <ele>42.4354248</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5251815" lon="9.759373">
        <ele>42.4354248</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5254697" lon="9.7591612">
        <ele>42.4354248</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.525681" lon="9.7590636">
        <ele>41.9547119</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5257403" lon="9.7588864">
        <ele>41.473999</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
      <trkpt lat="52.5259368" lon="9.758695">
        <ele>41.473999</ele>
        <time>2010-09-18T12:53:43.1924714+02:00</time>
      </trkpt>
    </trkseg>
  </trk>
</gpx>
------------------------------d10f7aa230e8
Content-Disposition: form-data; name="description"

beschreibung
------------------------------d10f7aa230e8
Content-Disposition: form-data; name="tags"

merkmale
------------------------------d10f7aa230e8
Content-Disposition: form-data; name="visibility"

private
------------------------------d10f7aa230e8--


++++++ end of data ++++++++++++++++++++++++++++

Last edited by mmr (2010-09-25 14:16:35)

Offline

#2 2010-09-22 01:35:12

Re: Uploading GPX File via API

OT: it's bad idea to post your Authorization token in header!!! it's only base64-encoded not safe and this forum is public! change your password now and edit this post!

Offline

#3 2011-05-20 15:38:44

Re: Uploading GPX File via API

i have the same Question.
Any Idea ?

I "wireshark" a josm upload which work correctly and tried to clone the network comunication.
But it dont work. I attach my both Session,maybe somebody has an Idea.

JOSM Session:

POST /api/0.6/gpx/create HTTP/1.1
Authorization: Basic nobodyknows
Content-Type: multipart/form-data; boundary=----------------------------d10f7aa230e8
Connection: close
User-Agent: JOSM/1.5 (4091 SVN de) Java/1.6.0_23
Host: www.openstreetmap.org
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Content-Length: 1966

------------------------------d10f7aa230e8
Content-Disposition: form-data; name="file"; filename="mini.gpx"
Content-Type: application/octet-stream

<?xml version='1.0' encoding='UTF-8'?>
<gpx version="1.1" creator="JOSM GPX export" xmlns="http://www.topografix.com/GPX/1/1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
  <metadata>
    <bounds minlat="51.956114799999995" minlon="9.3218994" maxlat="52.1191075" maxlon="9.8300171" />
  </metadata>
  <trk>    <name>Neue Positionsliste 1</name>
    <trkseg>
      <trkpt lat="52.119107500000496" lon="9.5800780000005">
        <time>2011-05-20T11:27:46.839Z</time>
        <name>NeuePosition 1</name>
        <ele>164.0</ele>
      </trkpt>
      <trkpt lat="52.032218104145315" lon="9.83001708984375">
        <time>2011-05-20T11:28:05.355Z</time>
        <name>NeuePosition 2</name>
        <ele>365.0</ele>
      </trkpt>
      <trkpt lat="51.95611479866181" lon="9.4537353515625">
        <time>2011-05-20T11:28:30.949Z</time>
        <name>NeuePosition 3</name>
        <ele>261.0</ele>
      </trkpt>
      <trkpt lat="52.08456959594681" lon="9.3218994140625">
        <time>2011-05-20T11:28:46.868Z</time>
        <name>NeuePosition 4</name>
        <ele>207.0</ele>
      </trkpt>
      <trkpt lat="52.11156571943228" lon="9.591064453125">
        <time>2011-05-20T11:28:34.136Z</time>
        <name>NeuePosition 5</name>
        <ele>151.0</ele>
      </trkpt>
    </trkseg>
  </trk>
</gpx>
------------------------------d10f7aa230e8
Content-Disposition: form-data; name="description"

mini
------------------------------d10f7aa230e8
Content-Disposition: form-data; name="tags"

meine merkmale
------------------------------d10f7aa230e8
Content-Disposition: form-data; name="visibility"

private
------------------------------d10f7aa230e8--
HTTP/1.1 200 OK
Date: Fri, 20 May 2011 12:07:44 GMT
Server: Apache/2.2.14 (Ubuntu)
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.7
Vary: Accept-Language,Accept-Encoding
ETag: "f7e708600bd1a79dd18c82c9fec9f3f2"
Content-Language: en
X-Runtime: 2418
Cache-Control: private, max-age=0, must-revalidate
Set-Cookie: _osm_session=709d057e2d0302c382c3d658f1e3ab33; path=/; HttpOnly
Content-Length: 7
Status: 200
Connection: close
Content-Type: text/plain; charset=utf-8

1013565

And now the session of my little Python app:

POST /api/0.6/gpx/create HTTP/1.1
Accept-Encoding: identity
Content-Length: 2023
Connection: close
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
User-Agent: JOSM/1.5 (4091 SVN de) Java/1.6.0_23
Host: www.openstreetmap.org
Content-Type: multipart/form-data; boundary=3788662a039c4bbcbb14e0fc1b4751b4
Authorization: Basic nowbodyknows

--3788662a039c4bbcbb14e0fc1b4751b4
Content-Disposition: form-data; name="visibility"
Content-Type: text/plain; charset=utf-8

private
--3788662a039c4bbcbb14e0fc1b4751b4
Content-Disposition: form-data; name="description"
Content-Type: text/plain; charset=utf-8

keine
--3788662a039c4bbcbb14e0fc1b4751b4
Content-Disposition: form-data; name="file"; filename="D:\\Data\\IGC\\mini.gpx"
Content-Type: text/plain; charset=utf-8

<?xml version='1.0' encoding='UTF-8'?>
<gpx version="1.1" creator="JOSM GPX export" xmlns="http://www.topografix.com/GPX/1/1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
  <metadata>
    <bounds minlat="51.956114799999995" minlon="9.3218994" maxlat="52.1191075" maxlon="9.8300171" />
  </metadata>
  <trk>    <name>Neue Positionsliste 1</name>
    <trkseg>
      <trkpt lat="52.119107500000496" lon="9.5800780000005">
        <time>2011-05-20T11:27:46.839Z</time>
        <name>NeuePosition 1</name>
        <ele>164.0</ele>
      </trkpt>
      <trkpt lat="52.032218104145315" lon="9.83001708984375">
        <time>2011-05-20T11:28:05.355Z</time>
        <name>NeuePosition 2</name>
        <ele>365.0</ele>
      </trkpt>
      <trkpt lat="51.95611479866181" lon="9.4537353515625">
        <time>2011-05-20T11:28:30.949Z</time>
        <name>NeuePosition 3</name>
        <ele>261.0</ele>
      </trkpt>
      <trkpt lat="52.08456959594681" lon="9.3218994140625">
        <time>2011-05-20T11:28:46.868Z</time>
        <name>NeuePosition 4</name>
        <ele>207.0</ele>
      </trkpt>
      <trkpt lat="52.11156571943228" lon="9.591064453125">
        <time>2011-05-20T11:28:34.136Z</time>
        <name>NeuePosition 5</name>
        <ele>151.0</ele>
      </trkpt>
    </trkseg>
  </trk>
</gpx>
--3788662a039c4bbcbb14e0fc1b4751b4
Content-Disposition: form-data; name="tags"
Content-Type: text/plain; charset=utf-8

meine
--3788662a039c4bbcbb14e0fc1b4751b4--
HTTP/1.1 500 Internal Server Error
Date: Fri, 20 May 2011 13:21:55 GMT
Server: Apache/2.2.14 (Ubuntu)
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.7
Vary: Accept-Language,Accept-Encoding
Content-Language: en
X-Runtime: 27
Cache-Control: no-cache
Error: NoMethodError: private method `split' called for #<File:/tmp/RackMultipart20110520-489-vgeepc-0>
Set-Cookie: _osm_session=7a2744ce80b19ac332b86b7f01c4bd56; path=/; HttpOnly
Content-Length: 96
Status: 500
Connection: close
Content-Type: text/html; charset=utf-8

NoMethodError: private method `split' called for #<File:/tmp/RackMultipart20110520-489-vgeepc-0>


And YES, i deleted my testtrack.

Last edited by telemaxx (2011-05-21 12:02:34)

Offline

#4 2011-05-21 11:26:19

Re: Uploading GPX File via API

mmr wrote:

I am trying to upload a GPX file to the public dev server via the API.

With what kind of program? Script? Language?

Please give an exact link to the documentation of that API.

Unfortunately I am only getting as response a 500 error code.

Nothing more? Not a description of the error? If not then did you look up what this error means? Please tell.

If this is your own program or script: wouldn't it be better you showed your code?

Offline

#5 2011-05-21 11:57:23

Re: Uploading GPX File via API

greencaps wrote:

With what kind of program? Script? Language?

In my case python. I want to write a logger for my Symbian Phone.
Should be part of my IGCLogger.
http://sites.google.com/site/pys60softw … r-features

greencaps wrote:

Please give an exact link to the documentation of that API.

http://wiki.openstreetmap.org/wiki/API_ … ing_Traces

Unfortunately I am only getting as response a 500 error code.

Nothing more? Not a description of the error? If not then did you look up what this error means? Please tell.
If this is your own program or script: wouldn't it be better you showed your code?

In my post before you see the complete Error message.

The python code:

from poster.encode import multipart_encode #http://atlee.ca/software/poster/
from poster.streaminghttp import register_openers
import urllib2
import base64
opener = register_openers()
params = {'file': open("D:\\Data\\IGC\\mini.gpx", "r"),'description':'no description','tags':'no tags',"visibility":"private"}

datagen, headers = multipart_encode(params)


request = urllib2.Request("http://www.openstreetmap.org/api/0.6/gpx/create", datagen, headers)
#auth = base64.encodestring('%s:%s' % ('my username', 'secret'))[:-1] # not sure using email or username
auth = "top secret"  # i use the string which josm has send
request.add_header('Authorization', 'Basic %s' % auth ) # Add Auth header to request
request.add_header('User-Agent', 'JOSM/1.5 (4091 SVN de) Java/1.6.0_23' ) # for testing josm as user agent
request.add_header('Accept', 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2')  # like josm did

result = urllib2.urlopen(request)

Last edited by telemaxx (2011-05-21 12:03:28)

Offline

#6 2011-05-23 10:52:41

Re: Uploading GPX File via API

telemaxx wrote:

In my post before you see the complete Error message.

Please give a quote.

But then... this was a question for mmr. What makes you think it is the same error?

Offline

#7 2011-05-27 20:12:33

Re: Uploading GPX File via API

i just wiresharked a "routeconverter" upload.
Same server response:

HTTP/1.1 500 Internal Server Error
Date: Fri, 27 May 2011 18:03:08 GMT
Server: Apache/2.2.14 (Ubuntu)
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.7
Vary: Accept-Language,Accept-Encoding
Content-Language: en
X-Runtime: 48
Cache-Control: no-cache
Error: NoMethodError: private method `split' called for #<File:/tmp/RackMultipart20110527-22469-hkksxl-0>
Set-Cookie: _osm_session=e43765b4d086aa3786514ee424b9b7a9; path=/; HttpOnly
Content-Length: 98
Status: 500
Connection: close
Content-Type: text/html; charset=utf-8
NoMethodError: private method `split' called for #<File:/tmp/RackMultipart20110527-22469-hkksxl-0>

Offline

Board footer

Powered by FluxBB 1.4.8
Hosting sponsored by Oxilion