I have OpenStreetMap hosted in my local server, I need help that how to add point in OpenStreetMap using API’s
I am trying this code to create point in my own server OSM but getting response 404 not found any help PLZ…
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
namespace YourNamespace.Controllers
{
public class NodeController : ApiController
{
[HttpPost]
public async Task CreateNode()
{
string url = “http://your_own_osm_server/api/0.6/node/create”;
// Construct the XML payload
string xmlData = $@"
<osm>
<node lat=""YOUR_LATITUDE"" lon=""YOUR_LONGITUDE"" version=""1"" changeset=""1"">
<tag k=""key1"" v=""value1""/>
<tag k=""key2"" v=""value2""/>
</node>
</osm>";
using (HttpClient client = new HttpClient())
{
// Create the HTTP content with XML payload
HttpContent content = new StringContent(xmlData, Encoding.UTF8, "application/xml");
// Make the POST request
HttpResponseMessage response = await client.PostAsync(url, content);
// Check if the request was successful
if (response.IsSuccessStatusCode)
{
return Ok("Node created successfully!");
}
else
{
return BadRequest("Failed to create node. Status code: " + response.StatusCode);
}
}
}
}
}