mmr
September 18, 2010, 11:46am
#1
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"?>
test
37.1480713
2010-09-18T12:53:43.1924714+02:00
36.6674805
2010-09-18T12:53:43.1924714+02:00
37.6286621
2010-09-18T12:53:43.1924714+02:00
38.109375
2010-09-18T12:53:43.1924714+02:00
39.0706787
2010-09-18T12:53:43.1924714+02:00
39.0706787
2010-09-18T12:53:43.1924714+02:00
39.0706787
2010-09-18T12:53:43.1924714+02:00
38.5900879
2010-09-18T12:53:43.1924714+02:00
40.5128174
2010-09-18T12:53:43.1924714+02:00
40.5128174
2010-09-18T12:53:43.1924714+02:00
41.9547119
2010-09-18T12:53:43.1924714+02:00
41.9547119
2010-09-18T12:53:43.1924714+02:00
42.9160156
2010-09-18T12:53:43.1924714+02:00
42.4354248
2010-09-18T12:53:43.1924714+02:00
41.473999
2010-09-18T12:53:43.1924714+02:00
40.9934082
2010-09-18T12:53:43.1924714+02:00
38.5900879
2010-09-18T12:53:43.1924714+02:00
38.109375
2010-09-18T12:53:43.1924714+02:00
37.6286621
2010-09-18T12:53:43.1924714+02:00
38.109375
2010-09-18T12:53:43.1924714+02:00
38.109375
2010-09-18T12:53:43.1924714+02:00
40.9934082
2010-09-18T12:53:43.1924714+02:00
41.473999
2010-09-18T12:53:43.1924714+02:00
42.4354248
2010-09-18T12:53:43.1924714+02:00
44.3580322
2010-09-18T12:53:43.1924714+02:00
42.9160156
2010-09-18T12:53:43.1924714+02:00
42.4354248
2010-09-18T12:53:43.1924714+02:00
41.9547119
2010-09-18T12:53:43.1924714+02:00
40.5128174
2010-09-18T12:53:43.1924714+02:00
40.0321045
2010-09-18T12:53:43.1924714+02:00
40.5128174
2010-09-18T12:53:43.1924714+02:00
40.0321045
2010-09-18T12:53:43.1924714+02:00
41.473999
2010-09-18T12:53:43.1924714+02:00
41.9547119
2010-09-18T12:53:43.1924714+02:00
40.5128174
2010-09-18T12:53:43.1924714+02:00
41.9547119
2010-09-18T12:53:43.1924714+02:00
42.4354248
2010-09-18T12:53:43.1924714+02:00
42.4354248
2010-09-18T12:53:43.1924714+02:00
41.9547119
2010-09-18T12:53:43.1924714+02:00
41.9547119
2010-09-18T12:53:43.1924714+02:00
41.9547119
2010-09-18T12:53:43.1924714+02:00
42.4354248
2010-09-18T12:53:43.1924714+02:00
42.4354248
2010-09-18T12:53:43.1924714+02:00
42.4354248
2010-09-18T12:53:43.1924714+02:00
41.9547119
2010-09-18T12:53:43.1924714+02:00
41.473999
2010-09-18T12:53:43.1924714+02:00
41.473999
2010-09-18T12:53:43.1924714+02:00
------------------------------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 ++++++++++++++++++++++++++++
b166er
(John Doe)
September 21, 2010, 11:35pm
#2
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!
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'?>
](http://www.topografix.com/GPX/1/1/gpx.xsd\ >)
Neue Positionsliste 1
2011-05-20T11:27:46.839Z
NeuePosition 1
164.0
2011-05-20T11:28:05.355Z
NeuePosition 2
365.0
2011-05-20T11:28:30.949Z
NeuePosition 3
261.0
2011-05-20T11:28:46.868Z
NeuePosition 4
207.0
2011-05-20T11:28:34.136Z
NeuePosition 5
151.0
------------------------------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'?>
](http://www.topografix.com/GPX/1/1/gpx.xsd\ >)
Neue Positionsliste 1
2011-05-20T11:27:46.839Z
NeuePosition 1
164.0
2011-05-20T11:28:05.355Z
NeuePosition 2
365.0
2011-05-20T11:28:30.949Z
NeuePosition 3
261.0
2011-05-20T11:28:46.868Z
NeuePosition 4
207.0
2011-05-20T11:28:34.136Z
NeuePosition 5
151.0
–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.
With what kind of program? Script? Language?
Please give an exact link to the documentation of that API.
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 case python. I want to write a logger for my Symbian Phone.
Should be part of my IGCLogger.
http://sites.google.com/site/pys60software/igclogger-features
http://wiki.openstreetmap.org/wiki/API_v0.6#Uploading_Traces
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)
Please give a quote.
But then… this was a question for mmr. What makes you think it is the same error?
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>