Data - Upload Preview

Data Upload API

Applies to: S1 pricing tier.

This API allows the caller to upload data content to the Azure Maps service.

You can use this API in a scenario like uploading a collection of Geofences in GeoJSON format for use in our Azure Maps Geofencing Service.

Submit Upload Request

To upload your content you will use a POST request where the request body will contain the data to upload, the dataFormat query parameter will contain the format for the data, the dataSharingLevel query parameter can contain the sharing level for the data and the Content-Type header will be set to the content type of the data.

For example, to upload a collection of geofences in GeoJSON format, set the request body to the geofence content, set the dataFormat query parameter to geojson and set the Content-Type header to either one of the following media types:

  • application/json
  • application/vnd.geo+json
  • application/octet-stream

Here's a sample request body for uploading a simple Geofence represented as a circle geometry in GeoJSON using a center point and a radius:


{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [-122.126986, 47.639754]
        },
        "properties": {
            "geometryId": "001",
            "radius": 500
        }
    }]
}


The Data Upload API is a long-running request with the following sequence of operations:

Send the upload request

  1. Client sends a Data Upload POST request to Azure Maps

  2. The server will respond with one of the following:

    HTTP 202 Accepted - Upload request has been accepted.

    HTTP Error - There was an error processing your Upload request. This could either be a 400 Bad Request or any other Error status code.

  3. If the Upload request was accepted successfully, the Location header in the response contains the status URI to check the current status of the long-running upload request. This status URI looks like the following:

https://atlas.microsoft.com/mapData/{udid}/status?api-version=1.0&subscription-key={subscription-key}    

Upload request "Accepted" but "In Progress"

  1. Client issues a GET request on the status URI obtained above to check the current status of the upload request.

  2. At this point, if the upload request is still being processed by Azure Maps, the client receives a HTTP 202 Accepted response. The Location header in the response contains the status URI to check the current status of the long-running upload request. The response body contains a more detailed status for the request which looks like:

{
    "status" : "In Progress"         
}

Upload request "Completed" successfully

  1. Client issues another GET request on the status URI to check the current upload status.

  2. At this point, if the upload request processing has completed successfully, the client receives a HTTP 201 Created response.

  3. The upload request was successful and the data has been created. The Location header in the response contains the URI to access/download the content in the future. The response body contains a unique data id (udid) for the data and looks like:

{
    "udid" : "d7e5efc8-2239-4387-a286-5bb51aa804e3"         
}

Upload request "Failed"

  1. Client issues another GET request on the status URI to check the current upload status.

  2. At this point, if the upload request processing has failed, the client receives a HTTP 204 No Content response.

  3. The request has failed and the data has not been created. The response body will contain a list of errors encountered while processing the upload request:

{
    "error": 
    {
      "code": "204 No Content",
      "message": "Upload data request failed. We encountered the following problems with your data: Map data is not a valid GeoJSON"
    }         
}

Data Upload Limits

Please, be aware that currently every Azure Maps account gets a free storage limit of 50 MB. This means that you can either upload 1 document of size 50 MB or 5 documents, each of size 10 MB or 100 documents, each of size 500 KB and so on. Once the free storage limit is reached, all the new upload API calls will return a 409 Conflict http error response. You can always use the Data Delete API to delete old/unused content and create space for new uploads.


POST https://atlas.microsoft.com/mapData/upload?api-version=1.0&dataFormat=geojson
POST https://atlas.microsoft.com/mapData/upload?subscription-key={subscription-key}&api-version=1.0&dataFormat=geojson

URI Parameters

Name In Required Type Description
subscription-key
query
  • string

One of the Azure Maps keys provided from an Azure Map Account. Refer to the subscription-key security definition.

api-version
query True
  • string

Version number of Azure Maps API. Current version is 1.0

dataFormat
query True

Data format of the content being uploaded. Currently, only geojson format is supported.

Request Header

Name Required Type Description
x-ms-client-id
  • string

Specifies which account is intended for usage in conjunction with the Azure AD security model. It represents a unique ID for the Azure Maps account and can be retrieved from Azure Maps management plane Account API. To use Azure AD security in Azure Maps see the following articles for guidance.

Request Body

Name Type Description
UploadContent
  • object

Responses

Name Type Description
201 Created

Content created/uploaded successfully. The Location header in the response contains the URI for accessing the content resource, for example - https://atlas.microsoft.com/mapData/{udid}?api-version=1.0&subscription-key={subscription-key}. The response body contains a unique data id udid for the content, for example - "udid": "25084fb7-307a-4720-8f91-7952a0b91012"

Headers

  • Location: string
  • Access-Control-Expose-Headers: string
202 Accepted

Upload data request has been Accepted. The upload process has not completed yet. The Location header in the response contains the uri for checking the status of the upload, for example - https://atlas.microsoft.com/mapData/{udid}/status?api-version=1.0&subscription-key={subscription-key}. The response body contains the current status for the upload, for example - "status": "Accepted"

Headers

  • Location: string
  • Access-Control-Expose-Headers: string
204 No Content

Data upload failed. The uploaded content did not satisfy all the validation checks. The response body contains all the errors that were encountered.

400 Bad Request

Bad request: one or more parameters were incorrectly specified or are mutually exclusive.

401 Unauthorized

Access denied due to invalid subscription key or invalid Azure Active Directory bearer token. Make sure to provide a valid key for an active Azure subscription and Maps resource. Otherwise, verify the WWW-Authenticate header for error code and description of the provided AAD bearer token.

Headers

  • WWW-Authenticate: string
403 Forbidden

Permission, capacity, or authentication issues.

404 Not Found

Not Found: the requested resource could not be found, but it may be available again in the future.

500 Internal Server Error

An error occurred while processing the request. Please try again later.

Security

azure_auth

These are the Azure Active Directory OAuth2 Flows. When paired with Azure Role Based Access control it can be used to control access to Azure Maps REST APIs. Azure Role based access controls are used to designate access to one or more Azure Maps resource account or sub-resources. Any user, group, or service principal can be granted access via a built in role or a custom role composed of one or more permissions to Azure Maps REST APIs.

To implement scenarios we recommend viewing authentication concepts. In summary, this security definition provides a solution for modeling application(s) via objects capable of access control on specific APIs and scopes.

Note

  • This security definition requires the use of the x-ms-client-id header to indicate which Azure Maps resource the application is requesting access to. This can be acquired from the Maps management API.
  • The Authorization URL is specific to the Azure public cloud instance. Sovereign clouds have unique Authorization URLs and Azure Active directory configurations.
  • The Azure role based access control is configured from the Azure management plane via Azure portal, Powershell, CLI, Azure SDKs, or REST APIs.
  • Usage of the Azure Maps Web SDK allows for configuration based setup of an application for multiple use cases.
  • Currently Azure Active Directory v1.0 tokens are supported.

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

subscription-key

This is a shared key which is provisioned when creating an Azure Maps resource through the Azure management plane via Azure portal, Powershell, CLI, Azure SDKs, or REST APIs. With this key, any application is authorized to access all REST APIs. In other words, these can currently be treated as master keys to the account which they are issued for. For publicly exposed applications our recommendation is to use server to server access of Azure Maps REST APIs where this key can be securely stored.

Type: apiKey
In: query

Examples

Upload GeoJSON data containing geometries that represent a collection of geofences

Sample Request

POST https://atlas.microsoft.com/mapData/upload?subscription-key=[subscription-key]&api-version=1.0&dataFormat=geojson
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -122.126986,
          47.639754
        ]
      },
      "properties": {
        "geometryId": "001",
        "radius": 500
      }
    }
  ]
}

Sample Response

Location: https://atlas.microsoft.com/mapData/{udid}?api-version=1.0&subscription-key={subscription-key}
Access-Control-Expose-Headers: Location
{
  "udid": "25084fb7-307a-4720-8f91-7952a0b91012"
}
Location: https://atlas.microsoft.com/mapData/{udid}/status?api-version=1.0&subscription-key={subscription-key}
Access-Control-Expose-Headers: Location
{
  "status": "Accepted"
}
{
  "error": {
    "code": "204 No Content",
    "message": "Map data upload failed. Map data upload failed. The uploaded content did not satisfy all the validation checks. The response body contains all the errors that were encountered."
  }
}
{
  "error": {
    "code": "400 BadRequest",
    "message": "Bad request: one or more parameters were incorrectly specified or are mutually exclusive."
  }
}
{
  "error": {
    "code": "401 Unauthorized",
    "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription."
  }
}
{
  "error": {
    "code": "403 Forbidden",
    "message": "Permission, capacity, or authentication issues."
  }
}
{
  "error": {
    "code": "404 NotFound",
    "message": "Not Found: the requested resource could not be found, but it may be available again in the future."
  }
}
{
  "error": {
    "code": "500 InternalServerError",
    "message": "An error occurred while processing the request. Please try again later."
  }
}

Definitions

Error

This object is returned when an error occurs in the Maps API

ErrorResponse

This response object is returned when an error occurs in the Maps API

MapDataUploadRequestAcceptedResponse

The response model for the Data Upload API for the case when the upload request was accepted, but the content wasn't created yet. This contains the current status of the long running upload operation.

MapDataUploadResponse

The response model for the Data Upload API for the case when the content was successfully uploaded. This contains a unique data id udid for the uploaded content.

UploadDataFormat

Data format of the content being uploaded. Currently, only geojson format is supported.

Error

This object is returned when an error occurs in the Maps API

Name Type Description
code
  • string

The HTTP status code.

message
  • string

If available, a human readable description of the error.

ErrorResponse

This response object is returned when an error occurs in the Maps API

Name Type Description
error

This object is returned when an error occurs in the Maps API

MapDataUploadRequestAcceptedResponse

The response model for the Data Upload API for the case when the upload request was accepted, but the content wasn't created yet. This contains the current status of the long running upload operation.

Name Type Description
status
  • string

Current status of the long running upload operation.

MapDataUploadResponse

The response model for the Data Upload API for the case when the content was successfully uploaded. This contains a unique data id udid for the uploaded content.

Name Type Description
udid
  • string

A unique data id udid for the uploaded content.

UploadDataFormat

Data format of the content being uploaded. Currently, only geojson format is supported.

Name Type Description
geojson
  • string

GeoJSON is a JSON based geospatial data interchange format.