[OSM-dev] Using API 0.6 to create a new node

toni hernández toni at sigte.udg.edu
Wed Jun 15 09:37:11 UTC 2016


Net yet..hopefully soon.

Sorry to be so persistent...but..
I am still getting a 401 Unauthorized error when sending the changeset 
create request.

Do I need to include the auth token in the header AJAX call?

This is how I try to create a new changeset:

var xml_string = '<?xml version="1.0" encoding="UTF-8"?> <osm 
version="0.6" generator="MyOpenstreetmapApp"><node changeset="0" 
lat="41.983910" lon="2.816094"><tag k="shop" 
v="supermarket"/></node></osm>';

ajaxurl= 
"http://master.apis.dev.openstreetmap.org/api/0.6/changeset/create";

$.ajax({
     url: ajaxurl,
     data: xml_new_changeset,
     type: 'PUT',
     contentType: "text/xml",
     dataType: "text",
     success : function (resp){console.debug(resp)},
     error : function (xhr, ajaxOptions, thrownError){
         console.log(xhr.status);
         console.log(thrownError);
     }
});


*Toni Hernández Vallès*
Servei de Sistemes d'Informació Geogràfica i Teledetecció
-
Universitat de Girona
*SIGTE*
-
Pl. Ferrater Mora 1
17071 Girona
Tel +34 972 418 039 (7026 intern)
toni at sigte.udg.edu <mailto:toni at sigte.udg.edu>

http://www.sigte.udg.edu
Twitter http://twitter.com/SIGTE_UDG

On 15/06/2016 11:20, Christian Ledermann wrote:
> If you can read python have a look at:
>
> https://github.com/cleder/osmoapi
>
> On 15 June 2016 at 09:57, Paul Norman <penorman at mac.com> wrote:
>> On 6/14/2016 8:41 AM, toni hernández wrote:
>>
>> Hi everyone,
>>
>> I am trying to display OSM data into my web map as well as other custom
>> layers.
>> One of the goals of my web application is to upload data from my application
>> to the osm database.  I have been reading this
>> http://wiki.openstreetmap.org/wiki/API_v0.6#Elements but still I do not
>> understand how a PUT request functions. I have so much to learn....
>>
>> After authentificating with osmauth.js I try this code without any success.
>> I get a 401 error.
>>
>> var xml_string = '<?xml version="1.0" encoding="UTF-8"?> <osm version="0.6"
>> generator="MyOpenstreetmapApp"><node changeset="0" lat="41.983910"
>> lon="2.816094"><tag k="shop" v="supermarket"/></node></osm>';
>>
>> ajaxurl= "http://www.openstreetmap.org/api/0.6/node/create";
>>
>>
>> I do not recommend the node/create API endpoint. Instead, use the diff
>> upload API call documented at
>> http://wiki.openstreetmap.org/wiki/API_v0.6#Diff_upload:_POST_.2Fapi.2F0.6.2Fchangeset.2F.23id.2Fupload.
>>
>> You will have to use this endpoint anyways for modifying existing data.
>>
>> _______________________________________________
>> dev mailing list
>> dev at openstreetmap.org
>> https://lists.openstreetmap.org/listinfo/dev
>>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20160615/c6e078cf/attachment-0001.html>


More information about the dev mailing list