TRN APIs

API change history

B2B REST APIs for the TRN Environment

submitOrder

Submit a new ADMIRALTY product order for a specified licence.

Try it

Request

Request URL

Request headers

  • string

    Authorisation JWT acquired from /auth/

  • (optional)
    string
    Media type of the body sent to the API.
  • string
    Subscription key which provides access to this API. Found in your Profile.

Request body

An order represented as JSON. Please see schema for more information.

{
  "purchaseOrderNumber": "string",
  "licenceId": 0,
  "ARCSRenewType": "New",
  "ADPRenewType": "New",
  "deliveryFromDate": "string",
  "deliveryToDate": "string",
  "deliveryMethod": "Email",
  "deliveryAddress": "string",
  "orderItems": [
    {
      "productType": "AVCSCharts",
      "productId": "string",
      "productPeriod": 0,
      "quantity": 0
    }
  ]
}
{
  "type": "object",
  "required": [
    "licenceId",
    "deliveryMethod",
    "orderItems"
  ],
  "properties": {
    "purchaseOrderNumber": {
      "type": "string",
      "maxLength": 20,
      "description": "Not Required. A reference given to an order by the Distributor."
    },
    "licenceId": {
      "type": "integer",
      "maxLength": 15,
      "description": "Required. The unique Licence ID given to each Vessel by the UKHO."
    },
    "ARCSRenewType": {
      "type": "string",
      "enum": [
        "New",
        "Add",
        "Renew"
      ],
      "description": "Required if the ARCS licence is within the last month before renewal. The type of order required if ordering ARCS products."
    },
    "ADPRenewType": {
      "type": "string",
      "enum": [
        "New",
        "Add",
        "Renew"
      ],
      "description": "Required if the ADP licence is within the last month before renewal. The type of order required if ordering ADP products. \"Renew\" -- Add ADP products to current licence and renew licence."
    },
    "deliveryFromDate": {
      "type": "string",
      "format": "date-time",
      "description": "Not required on \"digital\" only orders. Optional on orders including \"paper\" products. The required delivery from date (earliest delivery date), must be today's date or later. (Note: The time element is stored but not displayed in e-Navigator). Format: UTC YYYY-MM-DDThh:mm:ss E.g. 2012-1102T14:28:37.6613351+00:00 (Time and offset optional)."
    },
    "deliveryToDate": {
      "type": "string",
      "format": "date-time",
      "description": "Not required on \"digital\" only orders. Optional on orders including \"paper\" products. The required delivery to date (latest delivery date), must be today's date or later. (Note: The time element is stored but not displayed in e-Navigator). Format: UTC YYYY-MM-DDThh:mm:ss E.g. 2012-1102T14:28:37.6613351+00:00 (Time and offset optional)."
    },
    "deliveryMethod": {
      "type": "string",
      "enum": [
        "Email",
        "Download",
        "Both"
      ],
      "description": "Required. Permits and/or activation keys are provided either as downloads through GetOrder service or by email. The possible values: Email, Download, or Both."
    },
    "deliveryAddress": {
      "type": "string",
      "maxLength": 255,
      "description": "Not required on \"digital\" only orders. Optional on orders including \"paper\" products. A delivery address of an order."
    },
    "orderItems": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "productType",
          "productId"
        ],
        "properties": {
          "productType": {
            "type": "string",
            "description": "Required. The product type of the product to be ordered.",
            "enum": [
              "AVCSCharts",
              "ARCSCharts",
              "PaperCharts",
              "ADLL",
              "ADRS",
              "TotalTide",
              "ALL",
              "ALRS",
              "SDS",
              "TideTables",
              "Misc",
              "ENP",
              "ADRS6"
            ]
          },
          "productId": {
            "type": "string",
            "description": "Required. The product ID of the product to be ordered from the current ADMIRALTY catalogue, of the relevant product type. NOTE: this is case sensitive."
          },
          "productPeriod": {
            "type": "integer",
            "enum": [
              0,
              3,
              6,
              9,
              12
            ],
            "description": "Required for AVCS Charts. The period the product is required for in months. Accepts only: 3, 6, 9, or 12."
          },
          "quantity": {
            "type": "integer",
            "description": "Required for \"paper\" products. Not required for other products. The quantity of product required."
          }
        }
      },
      "description": "Required. The items in the order."
    }
  }
}

Responses

202 Accepted

Accepted - Indicates that the ADMIRALTY Order has been accepted and sent for processing. Please see response for the status of each ordered product.

Response headers

  • (optional)
    string

    GUID for the request for logging/tracing

Representations

{
  "orderStatus": [
    {
      "product": "AVCSCharts",
      "status": "Complete"
    },
    {
      "product": "ARCSCharts",
      "status": "Pending"
    }
  ],
  "accountId": 369,
  "orderId": 123456,
  "messages": [
    {
      "messageText": "Duplicates of AVCSCharts - GB123 have been found in the order and will be removed"
    }
  ]
}
{
  "type": "object",
  "properties": {
    "orderId": {
      "type": "integer"
    },
    "accountId": {
      "type": "integer"
    },
    "messages": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "orderStatus": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "product": {
            "type": "string"
          },
          "status": {
            "type": "string"
          }
        }
      }
    }
  }
}

400 Bad Request

Bad Request - The request is incomplete or fails validation:
- Missing the JWT
- Incorrect or missing data, please see response message for more details

Response headers

  • (optional)
    string

    GUID for the request for logging/tracing

Representations

{
  "correlationId": "6c254109-8a0f-4446-8649-721775ba9de2",
  "errors": [
    {
      "source": "token",
      "description": "Missing JWT"
    },
    {
      "source": "LicenceType",
      "description": "Licence not of type 'full' for ARCS."
    }
  ]
}
{
  "type": "object",
  "properties": {
    "correlationId": {
      "type": "string"
    },
    "errors": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        }
      }
    }
  }
}

401 Unauthorized

Token Authentication Failed

Response headers

  • (optional)
    string

    GUID for the request for logging/tracing

Representations

403 Forbidden

Forbidden or Quota Exceeded.
This will either be because:
- you have no permission to use this API (in which case the body will be empty)
- another distributor is responsible for a product you're trying to order on this licence
- the quota has been exceeded

Response headers

  • (optional)
    string

    GUID for the request for logging/tracing

Representations

{
  "statusCode": 403,
  "message": "Out of call volume quota. Quota will be replenished in 00:00:40."
}
{
  "type": "object",
  "properties": {
    "correlationId": {
      "type": "string"
    },
    "errors": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        }
      }
    }
  }
}

404 Not Found

Licence not found or Licence ID not provided.

Response headers

  • (optional)
    string

    GUID for the request for logging/tracing

Representations

{
  "correlationId": "6c254109-8a0f-4446-8649-721775ba9de2",
  "errors": [
    {
      "source": "licenceId",
      "description": "Licence ID not found."
    }
  ]
}
{
  "type": "object",
  "properties": {
    "correlationId": {
      "type": "string"
    },
    "errors": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        }
      }
    }
  }
}

409 Conflict

Conflict. Your order reference conflicts with a previous order reference.

Response headers

  • (optional)
    string

    GUID for the request for logging/tracing

Representations

429 Too many requests

Too Many Requests

Representations

{
  "statusCode": 429,
  "message": "Rate limit is exceeded. Try again in 1 seconds."
}
{
  "type": "object",
  "properties": {
    "statusCode": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  }
}

500 Internal Server Error

Internal Server Error.

Response headers

  • (optional)
    string

    GUID for the request for logging/tracing

Representations

{
  "correlationId": "string",
  "message": "string"
}
{
  "type": "object",
  "properties": {
    "correlationId": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  }
}

Code samples

@ECHO OFF

curl -v -X POST "https://admiralty.azure-api.net/trn/orders"
-H "token: "
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"

--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("token", "");
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");

            var uri = "https://admiralty.azure-api.net/trn/orders?" + queryString;

            HttpResponseMessage response;

            // Request body
            byte[] byteData = Encoding.UTF8.GetBytes("{body}");

            using (var content = new ByteArrayContent(byteData))
            {
               content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
               response = await client.PostAsync(uri, content);
            }

        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();

        try
        {
            URIBuilder builder = new URIBuilder("https://admiralty.azure-api.net/trn/orders");


            URI uri = builder.build();
            HttpPost request = new HttpPost(uri);
            request.setHeader("token", "");
            request.setHeader("Content-Type", "application/json");
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");


            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);

            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();

            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}

<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>

<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "https://admiralty.azure-api.net/trn/orders?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("token","");
                xhrObj.setRequestHeader("Content-Type","application/json");
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
            },
            type: "POST",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"https://admiralty.azure-api.net/trn/orders";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];

    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"POST"];
    // Request headers
    [_request setValue:@"" forHTTPHeaderField:@"token"];
    [_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];

    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];

    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://admiralty.azure-api.net/trn/orders');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'token' => '',
    'Content-Type' => 'application/json',
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
);

$request->setHeader($headers);

$parameters = array(
    // Request parameters
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_POST);

// Request body
$request->setBody("{body}");

try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

headers = {
    # Request headers
    'token': '',
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('admiralty.azure-api.net')
    conn.request("POST", "/trn/orders?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

headers = {
    # Request headers
    'token': '',
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.parse.urlencode({
})

try:
    conn = http.client.HTTPSConnection('admiralty.azure-api.net')
    conn.request("POST", "/trn/orders?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://admiralty.azure-api.net/trn/orders')


request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['token'] = ''
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"

response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body