You are not logged in.

Announcement

*** NOTICE: forum.openstreetmap.org is being retired. Please request a category for your community in the new ones as soon as possible using this process, which will allow you to propose your community moderators.
Please create new topics on the new site at community.openstreetmap.org. We expect the migration of data will take a few weeks, you can follow its progress here.***

#1 2011-01-28 12:51:07

paule85
Member
Registered: 2011-01-09
Posts: 7

Create: PUT /api/0.6/node/create = Problem to get the nodeId

Hello community,
I develop a POI editor but I have a problem to get the nodeId. I already got the changesetId.
The XMLHttpRequest is successful but I get an error in the response message where I normally have the nodeId.

The error message is: "</osm>. Fatal error: Extra content at the end of the document at :2."

It is not the whole code but I think the relevant code.

function createNewOsmNode(action){

    //XML
    var xmlOSM = "<\?xml version='1.0' encoding='UTF-8'\?>\n"
    xmlOSM += "<osm version=\"0.6\" generator=\"OpenStreetMap server\"> \n";
    xmlOSM += "<node id=\"" + nodeId + "\" changeset=\"" + changeSetId + "\" version=\"" + version + "\" lat=\"" + lat + "\" lon=\"" + lon + "\">\n";
    xmlOSM += xmlNode;
    xmlOSM += "</node>\n</osm>";
    // Sending content
    osmNode(action, xmlOSM);
}

function osmNode(action, data){

    var url =  host + "api/node.php";

    var params = new Object();
    params["action"] = action;
    params["changeset_id"] = changeSetId;
    params["node_id"] = nodeId;
    params["comment"] = commentId;
    params["userName"] = userName;
    params["userPassword"] = pwd;
    params["data"] = data;

    document.getElementById("saving").style.visibility = "visible";

    new Ajax.Request(url, {

        method: 'get',
        parameters: params,
        onSuccess: function(transport){
            var response = transport.responseText;
            switch (action){
                case "create":
                    nodeId = trim(response);   //here I got the error message and not the id.
                case "move":
                case "update":
                case "delete":
                    // updateOSM();
                    break;
            }
            document.getElementById("saving").style.visibility = "collapse";
            return "0";
        },
        onFailure: function(){
            document.getElementById("saving").style.visibility = "collapse";
            alert("crap");
            return "-1";
        },
        onException: function(request, exception){
            document.getElementById("saving").style.visibility = "collapse";
            alert("crap" + exception + request);
            return "-1";
        }
    });
}

Any ideas ?

greet Christian

Last edited by paule85 (2011-01-28 12:51:36)

Offline

#2 2011-01-28 15:23:26

greencaps
Member
Registered: 2009-10-05
Posts: 423

Re: Create: PUT /api/0.6/node/create = Problem to get the nodeId

paule85 wrote:

    var url =  host + "api/node.php";

What is the host?

And should not it be:  var url =  host + "node/create";


paule85 wrote:

        method: 'get',

To create a node the Put method has to be used as far as I know.

Well... just at first glance... i do not use Ajax myself...

Offline

#3 2011-01-28 17:19:44

paule85
Member
Registered: 2011-01-09
Posts: 7

Re: Create: PUT /api/0.6/node/create = Problem to get the nodeId

Thx for the answer.

Host is the base URL from my server and I am using the PUT method in the php file. There I send the parameters, the PUT method and the path (/api/0.6/node/create).
With the Ajax Request I want to get the nodeId as I did successfully with the changesetid.

Offline

#4 2011-01-30 18:17:15

paule85
Member
Registered: 2011-01-09
Posts: 7

Re: Create: PUT /api/0.6/node/create = Problem to get the nodeId

No idea ?

Offline

#5 2011-01-31 13:46:05

greencaps
Member
Registered: 2009-10-05
Posts: 423

Re: Create: PUT /api/0.6/node/create = Problem to get the nodeId

Your comments to my reply were so minimalistic that I thought that you were not really interested in a solution.

You did not tell the actual url you used.

As I understand you use an Ajax request. This requests invokes the call of a php page. What the
php page produces would be a nodeid if all went ok?

So why not concentrate on the php page itself? There the put method is used. The result of the put method
should be the id? Then what was the (error)result in the php page itself?

Offline

Board footer

Powered by FluxBB