Chilkat Online Tools

VB6 / easybill REST API / Fetch post box

Back to Collection Items

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

Dim http As New ChilkatHttp
Dim success As Long

http.SetRequestHeader "Authorization","{{apiKey}}"
http.SetRequestHeader "Accept","application/json"

Dim sbResponseBody As New ChilkatStringBuilder
success = http.QuickGetSb("https://api.easybill.de/rest/v1/post-boxes/:id",sbResponseBody)
If (success = 0) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Dim jResp As New ChilkatJsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0

Debug.Print "Response Body:"
Debug.Print jResp.Emit()

Dim respStatusCode As Long
respStatusCode = http.LastStatus
Debug.Print "Response Status Code = " & respStatusCode
If (respStatusCode >= 400) Then
    Debug.Print "Response Header:"
    Debug.Print http.LastHeader
    Debug.Print "Failed."
    Exit Sub
End If

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

' {
'   "id": "<long>",
'   "document_id": "<long>",
'   "to": "<string>",
'   "cc": "<string>",
'   "from": "<string>",
'   "subject": "<string>",
'   "message": "<string>",
'   "date": "<date>",
'   "created_at": "<dateTime>",
'   "processed_at": "<dateTime>",
'   "send_by_self": "<boolean>",
'   "send_with_attachment": "<boolean>",
'   "type": "EMAIL",
'   "status": "PROCESSING",
'   "status_msg": "<string>",
'   "login_id": "<long>",
'   "document_file_type": "default",
'   "post_send_type": "post_send_type_registered",
'   "tracking_identifier": "<string>"
' }

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

Dim id As String
id = jResp.StringOf("id")
Dim document_id As String
document_id = jResp.StringOf("document_id")
Dim v_to As String
v_to = jResp.StringOf("to")
Dim cc As String
cc = jResp.StringOf("cc")
Dim from As String
from = jResp.StringOf("from")
Dim subject As String
subject = jResp.StringOf("subject")
Dim message As String
message = jResp.StringOf("message")
Dim date As String
date = jResp.StringOf("date")
Dim created_at As String
created_at = jResp.StringOf("created_at")
Dim processed_at As String
processed_at = jResp.StringOf("processed_at")
Dim send_by_self As String
send_by_self = jResp.StringOf("send_by_self")
Dim send_with_attachment As String
send_with_attachment = jResp.StringOf("send_with_attachment")
Dim v_type As String
v_type = jResp.StringOf("type")
Dim status As String
status = jResp.StringOf("status")
Dim status_msg As String
status_msg = jResp.StringOf("status_msg")
Dim login_id As String
login_id = jResp.StringOf("login_id")
Dim document_file_type As String
document_file_type = jResp.StringOf("document_file_type")
Dim post_send_type As String
post_send_type = jResp.StringOf("post_send_type")
Dim tracking_identifier As String
tracking_identifier = jResp.StringOf("tracking_identifier")

Curl Command

curl -X GET
	-H "Authorization: {{apiKey}}"
	-H "Accept: application/json"
https://api.easybill.de/rest/v1/post-boxes/:id

Postman Collection Item JSON

{
  "name": "Fetch post box",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/post-boxes/:id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "post-boxes",
        ":id"
      ],
      "variable": [
        {
          "key": "id",
          "value": "<long>",
          "description": "(Required) ID of post box"
        }
      ]
    }
  },
  "response": [
    {
      "name": "Successful operation",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/post-boxes/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "post-boxes",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"id\": \"<long>\",\n  \"document_id\": \"<long>\",\n  \"to\": \"<string>\",\n  \"cc\": \"<string>\",\n  \"from\": \"<string>\",\n  \"subject\": \"<string>\",\n  \"message\": \"<string>\",\n  \"date\": \"<date>\",\n  \"created_at\": \"<dateTime>\",\n  \"processed_at\": \"<dateTime>\",\n  \"send_by_self\": \"<boolean>\",\n  \"send_with_attachment\": \"<boolean>\",\n  \"type\": \"EMAIL\",\n  \"status\": \"PROCESSING\",\n  \"status_msg\": \"<string>\",\n  \"login_id\": \"<long>\",\n  \"document_file_type\": \"default\",\n  \"post_send_type\": \"post_send_type_registered\",\n  \"tracking_identifier\": \"<string>\"\n}"
    },
    {
      "name": "Not found",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/post-boxes/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "post-boxes",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Too Many Requests",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/post-boxes/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "post-boxes",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}