Shipment API
API change historyREST JSON interface that exposes methods related to:
- Submitting a shipment to the notime platfom
- Checking a shipment's status
- Cancelling a shipment
- Updating shipment parameters after submission
5. Update Shipment
This method allows to update the parameters of a shipment, after the shipment has been submitted to the platform.
In particular it is possible to change the delivery times or the dropoff locations.
This method is also to be used in order to submit parcel information after the shipment has already been processed: For example this method might be called after picking of the products is completed and the number of parcels, barcodes and parcel sizes is now known.
Whether the shipment time windows or the dropoff location can still be changed depends on the status of the shipment. E.g. shortly before dropoff, only address changes few hundred meters from the original dropoff are allowed.
Dropoff notes can be added at any time and will be transmitted in real-time to the courier.
Shipments must be sent to the platform via the method Submit Shipment.
On successfully submitting a shipment to our platform the system returns a unique identifier for the shipment (shipment GUID). When updating a shipment , use this ID as the first parameter of the call.
Request
Request URL
Request headers
-
(optional)stringMedia type of the body sent to the API.
Request body
Name | Type | Mandatory | Note |
---|---|---|---|
ShipmentGuid | Guid | Yes | Guid identifying a shipment. The shipment GUID received when initially submitting the shipment. |
Action | Int | Yes |
|
Param | Object |
Additional Information to be provided depending on the action type.
|
|
Location | POI |
New dropoff location. It could be used in the following cases:
|
Name | Type | Mandatory | Default | Note |
---|---|---|---|---|
Reference | String | If this is provided we try to find the corresponding item in the database. If found the rest of the POI object can be empty (so use only reference to specify POI object). If, together with a valid reference, the fields Name, ContactName, Note, Phone are provided, they will be replaced in the corresponding database entry. If a new reference is entered, a new POI is created in the database. The reference has to be unique within a GroupGuid. | ||
Name | String | StreetAddress | ||
Phone | String | Main phone number. | ||
Phone2 | String | Additional phone number. | ||
Phone3 | String | Additional phone number. | ||
StreetAddress | String | Yes, if no valid Reference | ||
PostCode | String | Yes, if no valid Reference | ||
City | String | Yes, if no valid Reference | ||
CountryCode | String | Yes, if no valid Reference | Country code e.g. "CH", "DE", "FR", "AT" | |
ContactName | String | |||
ContactEmailAddress | String | |||
Note | String | |||
Labels | Array of String | Labels are used to describe the requirements that go with a certain shipment and the feature a deliverer offers. A typical requirement lable could mean: "Must be transported under 10C". "Must be transported flat". Labels are identified by their name. If this is provided we try to find it in the database otherwise it logs and error. |
Name | Type | Mandatory | Default | Note |
---|---|---|---|---|
ParcelNumber | String | No | 01 | Custom identifier of a parcel |
Barcode | String | Yes | ||
Size | String | No | Optional information about the size of the parcel. E.g. "XS", "S" etc. For more information please contact support. | |
Weight | Double | No | Optional information about the weight of the parcel in kg. |
Name | Type | Mandatory | Default | Note |
---|---|---|---|---|
ServiceId | Guid | Yes | The identifier (GUID) of the service. This GUID is received either via the Get Services method or from a list of hardcoded values. | |
Date | UTC Date string (YYYY-MM-DD) | Yes | Date of delivery |
{
"ShipmentGuid": "534efae5-8425-4b4b-85f4-c162470d8952",
"Action": "1",
"Param":
{
"Name":"Bar",
"Phone":"+41987654321",
"City":"Z\u00fcrich",
"CountryCode":"CH",
"Postcode":"8004",
"Streetaddress":"Badenerstrasse 97"
}
}
{
"ShipmentGuid": "534efae5-8425-4b4b-85f4-c162470d8952",
"Action": "4",
"Param": 10
}
{
"ShipmentGuid": "534efae5-8425-4b4b-85f4-c162470d8952",
"Action": "5",
"Param":
[{
"ParcelNumber":"01",
"Barcode": "9874561987319879431",
"Size": "S",
"Weight": 0.5
}]
}
{
"ShipmentGuid": "534efae5-8425-4b4b-85f4-c162470d8952",
"Action": "6",
"Param": "Additional pickup note for shipment"
}
{
"ShipmentGuid":"AA465025-0795-4938-8C1E-6FFC0ECD6EC6",
"Action":8,
"Param":{
"ServiceId":"3492052A-8FBB-43EF-ABD0-184F7D144BE3",
"Date":"2017-05-09"
},
"Location":{
"City":"Z\u00fcrich",
"CountryCode":"CH",
"Postcode":"8005",
"Streetaddress":"Giessereistrasse 18"
}
}
{
"ShipmentGuid": "534efae5-8425-4b4b-85f4-c162470d8952",
"Action": "9",
"Param": "New pickup note for shipment"
}
Responses
200 OK
Returned if the shipment has been changed successfully. The ResultCode is always set to "0" in this case.
Representations
{
"ResultCode": 0,
"ErrorString": null
}
400 Bad Request
Returned in cases where the submitted request body doesn't fit the validation rules or the business rules.
Code | Description |
---|---|
5 | Invalid timeslot given. |
6 | The given location can't be geocoded. |
7 | This location change is not, or no longer permitted. |
8 | This change of time window is no longer allowed. |
9 | The given delay parameter is outside of the allowed range. |
10 | The given new location is identical with the old one. (within 20 meter radius) |
11 | The given date time format is wrong |
16 | Invalid service given. |
18 | This service change is not, or no longer permitted. |
99 | General Error. Check the field ErrorString for more information |
Representations
{
"ResultCode": 99,
"ErrorString": "ShipmentGuid or ShipmentReference is not provided",
"Success": false
}
404 Not Found
Returned in case if specified shipment is not found.
Code samples
@ECHO OFF
curl -v -X POST "https://v1.notimeapi.com/api/shipment/update"
-H "Content-Type: Action 1"
-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("Ocp-Apim-Subscription-Key", "{subscription key}");
var uri = "https://v1.notimeapi.com/api/shipment/update?" + 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://v1.notimeapi.com/api/shipment/update");
URI uri = builder.build();
HttpPost request = new HttpPost(uri);
request.setHeader("Content-Type", "Action 1");
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://v1.notimeapi.com/api/shipment/update?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","Action 1");
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://v1.notimeapi.com/api/shipment/update";
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:@"Action 1" 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://v1.notimeapi.com/api/shipment/update');
$url = $request->getUrl();
$headers = array(
// Request headers
'Content-Type' => 'Action 1',
'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
'Content-Type': 'Action 1',
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.urlencode({
})
try:
conn = httplib.HTTPSConnection('v1.notimeapi.com')
conn.request("POST", "/api/shipment/update?%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
'Content-Type': 'Action 1',
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.parse.urlencode({
})
try:
conn = http.client.HTTPSConnection('v1.notimeapi.com')
conn.request("POST", "/api/shipment/update?%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://v1.notimeapi.com/api/shipment/update')
request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'Action 1'
# 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