Chilkat Online Tools

PowerBuilder / DHL Express APIs (MyDHL API) / Electronic Proof of Delivery

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_EncodingFormat
string ls_Content
string ls_TypeCode
integer i
integer li_Count_i

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Http.BasicAuth = 1
loo_Http.Login = "<Basic Auth Username>"
loo_Http.Password = "<Basic Auth Password>"

loo_QueryParams = create oleobject
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_QueryParams.UpdateString("shipperAccountNumber","Ut aliqua")
loo_QueryParams.UpdateString("content","epod-summary")

loo_Http.SetRequestHeader("Webstore-Platform-Name","")
loo_Http.SetRequestHeader("Shipping-System-Platform-Name","")
loo_Http.SetRequestHeader("Message-Reference","d0e7832e-5c98-11ea-bc55-0242ac13")
loo_Http.SetRequestHeader("Plugin-Version","")
loo_Http.SetRequestHeader("Plugin-Name","")
loo_Http.SetRequestHeader("Shipping-System-Platform-Version","")
loo_Http.SetRequestHeader("Accept","application/json")
loo_Http.SetRequestHeader("Message-Reference-Date","Wed, 21 Oct 2015 07:28:00 GMT")
loo_Http.SetRequestHeader("Webstore-Platform-Version","")

loo_Resp = loo_Http.QuickRequestParams("GET","https://api-mock.dhl.com/mydhlapi/shipments/:shipmentTrackingNumber/proof-of-delivery",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "documents": [
//     {
//       "encodingFormat": "PDF",
//       "content": "base64 encoded content",
//       "typeCode": "POD"
//     },
//     {
//       "encodingFormat": "PDF",
//       "content": "base64 encoded content",
//       "typeCode": "POD"
//     }
//   ]
// }

// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

i = 0
li_Count_i = loo_JResp.SizeOfArray("documents")
do while i < li_Count_i
    loo_JResp.I = i
    ls_EncodingFormat = loo_JResp.StringOf("documents[i].encodingFormat")
    ls_Content = loo_JResp.StringOf("documents[i].content")
    ls_TypeCode = loo_JResp.StringOf("documents[i].typeCode")
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -G -d "shipperAccountNumber=Ut%20aliqua"
	-d "content=epod-summary"
	-u '<Basic Auth Username>:<Basic Auth Password>'
	-H "Message-Reference: d0e7832e-5c98-11ea-bc55-0242ac13"
	-H "Message-Reference-Date: Wed, 21 Oct 2015 07:28:00 GMT"
	-H "Plugin-Name:  "
	-H "Plugin-Version:  "
	-H "Shipping-System-Platform-Name:  "
	-H "Shipping-System-Platform-Version:  "
	-H "Webstore-Platform-Name:  "
	-H "Webstore-Platform-Version:  "
	-H "Accept: application/json"
https://api-mock.dhl.com/mydhlapi/shipments/:shipmentTrackingNumber/proof-of-delivery

Postman Collection Item JSON

{
  "name": "Electronic Proof of Delivery",
  "request": {
    "method": "GET",
    "header": [
      {
        "description": "Please provide message reference\n",
        "key": "Message-Reference",
        "value": "d0e7832e-5c98-11ea-bc55-0242ac13"
      },
      {
        "description": "Optional reference date in the  HTTP-date format https://tools.ietf.org/html/rfc7231#section-7.1.1.2",
        "key": "Message-Reference-Date",
        "value": "Wed, 21 Oct 2015 07:28:00 GMT"
      },
      {
        "description": "Please provide name of the plugin (applicable to 3PV only)\n",
        "key": "Plugin-Name",
        "value": " "
      },
      {
        "description": "Please provide version of the plugin (applicable to 3PV only)\n",
        "key": "Plugin-Version",
        "value": " "
      },
      {
        "description": "Please provide name of the shipping platform(applicable to 3PV only)\n",
        "key": "Shipping-System-Platform-Name",
        "value": " "
      },
      {
        "description": "Please provide version of the shipping platform (applicable to 3PV only)\n",
        "key": "Shipping-System-Platform-Version",
        "value": " "
      },
      {
        "description": "Please provide name of the webstore platform (applicable to 3PV only)\n",
        "key": "Webstore-Platform-Name",
        "value": " "
      },
      {
        "description": "Please provide version of the webstore platform (applicable to 3PV only)\n",
        "key": "Webstore-Platform-Version",
        "value": " "
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/shipments/:shipmentTrackingNumber/proof-of-delivery?shipperAccountNumber=Ut aliqua&content=epod-summary",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "shipments",
        ":shipmentTrackingNumber",
        "proof-of-delivery"
      ],
      "query": [
        {
          "key": "shipperAccountNumber",
          "value": "Ut aliqua",
          "description": "DHL Express customer shipper account number"
        },
        {
          "key": "content",
          "value": "epod-summary"
        }
      ],
      "variable": [
        {
          "key": "shipmentTrackingNumber",
          "value": "dolor veniam officia non",
          "description": "(Required) DHL Express shipment identification number"
        }
      ]
    },
    "description": "The electronic proof of delivery service can be used to retrieve proof of delivery for certain delivered DHL Express shipments\n"
  },
  "response": [
    {
      "name": "Electronic Proof of delivery found",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          },
          {
            "description": "Please provide message reference\n",
            "key": "Message-Reference",
            "value": "d0e7832e-5c98-11ea-bc55-0242ac13"
          },
          {
            "description": "Optional reference date in the  HTTP-date format https://tools.ietf.org/html/rfc7231#section-7.1.1.2",
            "key": "Message-Reference-Date",
            "value": "Wed, 21 Oct 2015 07:28:00 GMT"
          },
          {
            "description": "Please provide name of the plugin (applicable to 3PV only)\n",
            "key": "Plugin-Name",
            "value": " "
          },
          {
            "description": "Please provide version of the plugin (applicable to 3PV only)\n",
            "key": "Plugin-Version",
            "value": " "
          },
          {
            "description": "Please provide name of the shipping platform(applicable to 3PV only)\n",
            "key": "Shipping-System-Platform-Name",
            "value": " "
          },
          {
            "description": "Please provide version of the shipping platform (applicable to 3PV only)\n",
            "key": "Shipping-System-Platform-Version",
            "value": " "
          },
          {
            "description": "Please provide name of the webstore platform (applicable to 3PV only)\n",
            "key": "Webstore-Platform-Name",
            "value": " "
          },
          {
            "description": "Please provide version of the webstore platform (applicable to 3PV only)\n",
            "key": "Webstore-Platform-Version",
            "value": " "
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/shipments/:shipmentTrackingNumber/proof-of-delivery?shipperAccountNumber=Ut aliqua&content=epod-summary",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "shipments",
            ":shipmentTrackingNumber",
            "proof-of-delivery"
          ],
          "query": [
            {
              "key": "shipperAccountNumber",
              "value": "Ut aliqua"
            },
            {
              "key": "content",
              "value": "epod-summary"
            }
          ],
          "variable": [
            {
              "key": "shipmentTrackingNumber",
              "value": "dolor veniam officia non",
              "description": "(Required) DHL Express shipment identification number"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Invocation-Id",
          "value": "sed ut mollit",
          "description": "Unique identifier of the transaction"
        },
        {
          "key": "Message-Reference",
          "value": "sed ut mollit",
          "description": "Message reference provided by customer as part of reqeust or automatically generated when not provided"
        },
        {
          "key": "Content-Language",
          "value": "sed ut mollit",
          "description": ""
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"documents\": [\n    {\n      \"encodingFormat\": \"PDF\",\n      \"content\": \"base64 encoded content\",\n      \"typeCode\": \"POD\"\n    },\n    {\n      \"encodingFormat\": \"PDF\",\n      \"content\": \"base64 encoded content\",\n      \"typeCode\": \"POD\"\n    }\n  ]\n}"
    },
    {
      "name": "Wrong input parameters",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          },
          {
            "description": "Please provide message reference\n",
            "key": "Message-Reference",
            "value": "d0e7832e-5c98-11ea-bc55-0242ac13"
          },
          {
            "description": "Optional reference date in the  HTTP-date format https://tools.ietf.org/html/rfc7231#section-7.1.1.2",
            "key": "Message-Reference-Date",
            "value": "Wed, 21 Oct 2015 07:28:00 GMT"
          },
          {
            "description": "Please provide name of the plugin (applicable to 3PV only)\n",
            "key": "Plugin-Name",
            "value": " "
          },
          {
            "description": "Please provide version of the plugin (applicable to 3PV only)\n",
            "key": "Plugin-Version",
            "value": " "
          },
          {
            "description": "Please provide name of the shipping platform(applicable to 3PV only)\n",
            "key": "Shipping-System-Platform-Name",
            "value": " "
          },
          {
            "description": "Please provide version of the shipping platform (applicable to 3PV only)\n",
            "key": "Shipping-System-Platform-Version",
            "value": " "
          },
          {
            "description": "Please provide name of the webstore platform (applicable to 3PV only)\n",
            "key": "Webstore-Platform-Name",
            "value": " "
          },
          {
            "description": "Please provide version of the webstore platform (applicable to 3PV only)\n",
            "key": "Webstore-Platform-Version",
            "value": " "
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/shipments/:shipmentTrackingNumber/proof-of-delivery?shipperAccountNumber=Ut aliqua&content=epod-summary",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "shipments",
            ":shipmentTrackingNumber",
            "proof-of-delivery"
          ],
          "query": [
            {
              "key": "shipperAccountNumber",
              "value": "Ut aliqua"
            },
            {
              "key": "content",
              "value": "epod-summary"
            }
          ],
          "variable": [
            {
              "key": "shipmentTrackingNumber",
              "value": "dolor veniam officia non",
              "description": "(Required) DHL Express shipment identification number"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"instance\": \"/expressapi/shipments/1234567890/proof-of-delivery\",\n  \"title\": \"Bad request\",\n  \"message\": \"Bad request\",\n  \"status\": \"400\"\n}"
    },
    {
      "name": "No electronic proof of delivery found",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          },
          {
            "description": "Please provide message reference\n",
            "key": "Message-Reference",
            "value": "d0e7832e-5c98-11ea-bc55-0242ac13"
          },
          {
            "description": "Optional reference date in the  HTTP-date format https://tools.ietf.org/html/rfc7231#section-7.1.1.2",
            "key": "Message-Reference-Date",
            "value": "Wed, 21 Oct 2015 07:28:00 GMT"
          },
          {
            "description": "Please provide name of the plugin (applicable to 3PV only)\n",
            "key": "Plugin-Name",
            "value": " "
          },
          {
            "description": "Please provide version of the plugin (applicable to 3PV only)\n",
            "key": "Plugin-Version",
            "value": " "
          },
          {
            "description": "Please provide name of the shipping platform(applicable to 3PV only)\n",
            "key": "Shipping-System-Platform-Name",
            "value": " "
          },
          {
            "description": "Please provide version of the shipping platform (applicable to 3PV only)\n",
            "key": "Shipping-System-Platform-Version",
            "value": " "
          },
          {
            "description": "Please provide name of the webstore platform (applicable to 3PV only)\n",
            "key": "Webstore-Platform-Name",
            "value": " "
          },
          {
            "description": "Please provide version of the webstore platform (applicable to 3PV only)\n",
            "key": "Webstore-Platform-Version",
            "value": " "
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/shipments/:shipmentTrackingNumber/proof-of-delivery?shipperAccountNumber=Ut aliqua&content=epod-summary",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "shipments",
            ":shipmentTrackingNumber",
            "proof-of-delivery"
          ],
          "query": [
            {
              "key": "shipperAccountNumber",
              "value": "Ut aliqua"
            },
            {
              "key": "content",
              "value": "epod-summary"
            }
          ],
          "variable": [
            {
              "key": "shipmentTrackingNumber",
              "value": "dolor veniam officia non",
              "description": "(Required) DHL Express shipment identification number"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"instance\": \"/expressapi/shipments/1234567890/proof-of-delivery\",\n  \"title\": \"No data found\",\n  \"status\": \"404\"\n}"
    }
  ]
}