Works on sandbox API, doesn't work on main API


I wrote a small PHP script to import all the Romanian settlement boundaries and it was working fine on However when I switched the to I keep getting bad request errors.

Here’s the code that creates a changeset. It works fine on the sandbox but doesn’t on the main API:

$server = '';

$put_file = fopen('tmp/tmpfile', 'w+');
fwrite($put_file, $create_changeset_data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://'.$server.'/api/0.6/changeset/create');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $put_file);
curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$password);
$changeset_id = curl_exec($ch);

In $create_changeset_data I have the following:

        <tag k="created_by" v="Romanian Settlement Boundaries v0.1"/>
        <tag k="comment" v="Boundaries for Bicaz / Source: Mircea Angelescu ("/>

The provided user / password combination works and I can write tmp/tmpfile.

I don’t get it, isn’t the sandbox supposed to be exactly the same as the main API? What’s the use of it if it’s not? :frowning:

The error I’m getting is here:

Content-Length: 47
Is 47 enough? The url itself is 53 and without the protocol specification 46. I’m a little bit out of this but should not Content-Length include the put content? It looks as if the file was not sent.

Error: Cannot parse valid Changeset from xml string .
Because nothing is received?

It now appears that kitsched posted this problem on the dev mailing list too:

And got it solved the same day.

So I could better have done something else yesterday.