NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

i am using PHP - Curl to Upload GPX traces.

$fields_file          = '2004062.gpx';
$fields_description   = 'Sample Description';
$fields_tags          = 'public';
$fields_visibility    = 'public';

$FF['file']         = $fields_file;
$FF['description']  = $fields_description;
$FF['tags']         = $fields_tags;
$FF['visibility']   = $fields_visibility;

http_build_query($FF);

$OSMuser = 'csrm.xxxxxxx@gmail.com';
$OSMpass = 'xxxxxxx*';
$host    = 'http://api.openstreetmap.org/api/0.6/gpx/create';
$agent   = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$process = curl_init($host);
curl_setopt($process, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));
curl_setopt($process, CURLOPT_HEADER, 1);
curl_setopt($process, CURLOPT_USERPWD, $OSMuser . ":" . $OSMpass);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
curl_setopt($process, CURLOPT_POSTFIELDS, http_build_query($FF));
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($process, CURLOPT_USERAGENT, $agent);
$return = curl_exec($process);
curl_close($process);

Response:

string(472) "HTTP/1.1 400 Bad Request
Date: Thu, 30 Jul 2015 06:29:14 GMT
Server: Apache/2.4.7 (Ubuntu)
Cache-Control: no-cache
Vary: Accept-Language,Origin
X-XSS-Protection: 1; mode=block
Content-Language: en
X-Request-Id: VbnEOn8AAQEAAG2TtpMAAAAZ
X-Runtime: 0.012558
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-Powered-By: Phusion Passenger 5.0.14
Status: 400 Bad Request
Content-Length: 0
Connection: close
Content-Type: text/html; charset=utf-8

asked 30 Jul '15, 08:20

CSRM%20Kozhikode's gravatar image

CSRM Kozhikode
11112
accept rate: 0%

edited 30 Jul '15, 08:38

scai's gravatar image

scai ♦
33.3k21309459

I don't know the reason for the 400 status code but you should not send a wrong user agent.

(30 Jul '15, 08:40) scai ♦

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×255
×117
×34

question asked: 30 Jul '15, 08:20

question was seen: 3,690 times

last updated: 30 Jul '15, 09:09

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum