Deliveries are made to Marketplace by posting XML-formatted data to the endpoint for the corresponding data type.
The base URL to the product import-API is:
https://mis.cdon.com/<data_type>
Responses are returned with a HTTP status code and possibly a body in JSON-format.
Each delivery that is acceptable (according to the data contract) receives a receipt. Make sure to store this, as it is the key to tracking the progress of the delivery.
Authentication
For security reasons, all HTTP requests to the API must include a Authorization header.
The value of the header shall be the API token, prefixed by the word api and a whitespace. Example:
Authorization: api 5875ca6c-229d-4f4c-a45f-4252b4583538
Tracking
To be able to track your import you can call the Deliveries-endpoint. The response from that endpoint is a package containing e.g. status, errorMessages, etc.
The drawback of calling this endpoint is that it has to be called over and over again as long as status = Pending.
There is another feature that enables a call from the CDON import to an endpoint that you provide. You have to implement an HTTP receiver on your end that receives a POST with a payload that is identical to the response payload from the Deliveries-endpoint. This is an example of a package:
{ "receiptId": "08d7b39138632b550003ffdf013b0000", "startTime": "2020-02-17T00:00:00.000000+00:00", "endTime": "2020-02-17T00:00:10.000000+00:00", "endPoint": "Product", "status": "Failed", "errorMessage": "null", "total": 2, "totalPending": 0, "totalSucceeded": 1, "totalFailed": 1, "estimatedTimeLeft": "1s" }
To specify this receving enpoint to the import you have to provide a header in a call to:
The name of the header is 'callbackUrl'. The value is your Url.
If the import has Failed then you can call the Failures endpoint to find out what the errors are.
Data Contracts
As mentioned in validation, a pre-validation is performed on the delivery. This validation is based on a data contract specified in a set of XSD files.
The location of the schema files is:
Use these files to generate XML and validate against them to avoid submitting invalid data.
Example
C#
public async Task<Guid> SendFile(string filePath) { var r = WebRequest.Create("https://mis.cdon.com/product"); r.Method = "POST"; r.ContentType = "application/xml"; r.Headers.Add("authorization", "api XXX"); using (var fileStream = File.OpenRead(filePath)) using (var targetStream = r.GetRequestStream()) { await fileStream.CopyToAsync(targetStream); await targetStream.FlushAsync(); } using (var response = await r.GetResponseAsync()) using (var responseStream = response.GetResponseStream()) using (var streamReader = new StreamReader(responseStream)) using (var jsonReader = new JsonTextReader(streamReader)) { var serializer = new JsonSerializer(); var result = serializer.Deserialize<dynamic>(jsonReader); return result.receiptId; } }