Chilkat Online Tools

PowerBuilder / Plivo REST API / List all messages

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.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 = "{{auth_id}}"
loo_Http.Password = "password"

loo_QueryParams = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject")

loo_QueryParams.UpdateString("message_state","undelivered")

loo_Resp = loo_Http.QuickRequestParams("GET","https://api.plivo.com/v1/Account/<auth_id>/Message/",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp


destroy loo_Http
destroy loo_QueryParams

Curl Command

curl -G -d "message_state=undelivered"
	-u '{{auth_id}}:password'
https://api.plivo.com/v1/Account/<auth_id>/Message/

Postman Collection Item JSON

{
  "name": "List all messages",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Message/?message_state=undelivered",
      "protocol": "https",
      "host": [
        "api",
        "plivo",
        "com"
      ],
      "path": [
        "v1",
        "Account",
        "{{auth_id}}",
        "Message",
        ""
      ],
      "query": [
        {
          "key": "subaccount",
          "value": "<subaccount_auth>",
          "description": "1. Outbound messages sent using a specific sub-account's auth token.\n2. Inbound messages received on a phone number associated with a specific sub-account.",
          "disabled": true
        },
        {
          "key": "message_direction",
          "value": "outbound",
          "description": "Use this argument to filter the results by message direction. The valid inputs are inbound and outbound.",
          "disabled": true
        },
        {
          "key": "message_time",
          "value": "2020-11-19 05:45:30.738800",
          "description": "The timestamps are expected to in YYYY-MM-DD HH:MM[:ss[.uuuuuu]] format, and are considered to be in UTC timezone.",
          "disabled": true
        },
        {
          "key": "message_state",
          "value": "undelivered",
          "description": "Use this argument to filter by the current status of a message. This argument can be set to one of following states : queued, sent, failed, delivered, undelivered, received or rejected"
        },
        {
          "key": "message_type",
          "value": "sms",
          "description": "Use this argument to filter results by the type of message - sms or mms.",
          "disabled": true
        },
        {
          "key": "error_code\n",
          "value": "100",
          "description": "Use this argument to filter results by a standard Plivo error code. Read more about Plivo SMS error codes here.",
          "disabled": true
        },
        {
          "key": "limit",
          "value": "5",
          "description": "Used to display the number of results per page. The maximum number of results that can be fetched is 20. Defaults to 20.",
          "disabled": true
        },
        {
          "key": "offset",
          "value": "20",
          "description": "Denotes the number of value items by which the results should be offset. Defaults to 0. Read more about offset based pagination here.",
          "disabled": true
        }
      ]
    },
    "description": "This API can be used to fetch a list of message detail records (MDRs) based on a filter criteria. More information can be found [here](https://www.plivo.com/docs/sms/api/message#list-all-messages)\n\n| Arguments   | Description | Required/Conditional/Optional     |\n| :---        |    :----:   |          ---: |\n| subaccount      | Use this argument to filter for.<br /> - Outbound messages sent using a specific sub-account's auth token. <br /> - Inbound messages received on a phone number associated with a specific sub-account.| Optional  |\n| message_direction | Use this argument to filter the results by message direction. The valid inputs are inbound and outbound.      | Optional      |\n| message_time   | Forms of this parameter can be used to filter outbound/inbound messages based on the time the message was initiated/received.<br />The timestamps are expected to in YYYY-MM-DD HH:MM[:ss[.uuuuuu]] format, and are considered to be in UTC timezone.<br />The filter can be used in the following five forms:<br />message_time: Use this argument to filter for messages by the exact timestamp. The format expected is YYYY-MM-DD HH:MM:ss:uuuuuu. Eg: To get all messages that were sent/received at 2012-03-21 11:47:30.982811, use message_time=2012-03-21 11:47:30.982811<br />message_time__gt: gt stands for greater than. Use this argument to filter for messages sent/received after a given time. Eg: To get all messages that were sent/received after 2012-03-21 11:47, use message_time__gt=2012-03-21 11:47<br />message_time__gte: gte stands for greater than or equal. Eg: To get all messages that were sent/received after or exactly at 2012-03-21 11:47[:30], use message_time__gte=2012-03-21 11:47[:30]<br />message_time__lt: lt stands for lesser than. Use this argument to filter for messages sent/received before a given time. Eg: To get all messages that were sent/received before 2012-03-21 11:47, use message_time__lt=2012-03-21 11:47<br />message_time__lte: lte stands for lesser than or equal. Eg: To get all messages that were sent/received before or exactly at 2012-03-21 11:47[:30], use message_time__lte=2012-03-21 11:47[:30] | Optional |\n| message_state   | Use this argument to filter by the current status of a message. This argument can be set to one of following states : queued, sent, failed, delivered, undelivered, received or rejected.| Optional |\n| message_type | Use this argument to filter results by the type of message - sms or mms. | Optional      |\n| error_code   | Use this argument to filter results by a standard Plivo error code        | Optional      |\n| limit   | Used to display the number of results per page. The maximum number of results that can be fetched is 20. Defaults to 20.        | Optional      |\n| offset   |Denotes the number of value items by which the results should be offset. Defaults to 0     | Optional      |"
  },
  "response": [
    {
      "name": "List all messages",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Message/?limit=2&offset=0",
          "protocol": "https",
          "host": [
            "api",
            "plivo",
            "com"
          ],
          "path": [
            "v1",
            "Account",
            "{{auth_id}}",
            "Message",
            ""
          ],
          "query": [
            {
              "key": "subaccount",
              "value": "<subaccount_auth>",
              "description": "1. Outbound messages sent using a specific sub-account's auth token.\n2. Inbound messages received on a phone number associated with a specific sub-account.",
              "disabled": true
            },
            {
              "key": "message_direction",
              "value": "outbound",
              "description": "Use this argument to filter the results by message direction. The valid inputs are inbound and outbound.",
              "disabled": true
            },
            {
              "key": "message_time",
              "value": "2020-11-19 05:45:30.738800",
              "description": "The timestamps are expected to in YYYY-MM-DD HH:MM[:ss[.uuuuuu]] format, and are considered to be in UTC timezone.",
              "disabled": true
            },
            {
              "key": "message_state",
              "value": "undelivered",
              "description": "Use this argument to filter by the current status of a message. This argument can be set to one of following states : queued, sent, failed, delivered, undelivered, received or rejected",
              "disabled": true
            },
            {
              "key": "message_type",
              "value": "sms",
              "description": "Use this argument to filter results by the type of message - sms or mms.",
              "disabled": true
            },
            {
              "key": "error_code\n",
              "value": "100",
              "description": "Use this argument to filter results by a standard Plivo error code. Read more about Plivo SMS error codes here.",
              "disabled": true
            },
            {
              "key": "limit",
              "value": "2",
              "description": "Used to display the number of results per page. The maximum number of results that can be fetched is 20. Defaults to 20."
            },
            {
              "key": "offset",
              "value": "0",
              "description": "Denotes the number of value items by which the results should be offset. Defaults to 0. Read more about offset based pagination here."
            }
          ]
        }
      },
      "_postman_previewlanguage": "json",
      "header": [
      ],
      "cookie": [
      ],
      "body": "{\n    \"api_id\": \"88415194-6df0-11e6-b608-06a72a185e87\",\n    \"meta\": {\n        \"limit\": 2,\n        \"next\": \"/v1/Account/{auth_id}/Message/?limit=20&error_code=200&offset=20\",\n        \"offset\": 0,\n        \"previous\": null,\n        \"total_count\": 22\n    },\n    \"objects\": [\n        {\n            \"error_code\": \"200\",\n            \"from_number\": \"18552828641\",\n            \"message_direction\": \"outbound\",\n            \"message_state\": \"failed\",\n            \"message_time\": \"2016-08-17 21:26:44+05:30\",\n            \"message_type\": \"sms\",\n            \"message_uuid\": \"85ce8068-6fab-4f0a-9dc7-d6c852cdde91\",\n            \"resource_uri\": \"/v1/Account/{auth_id}/Message/85ce8068-6fab-4f0a-9dc7-d6c852cdde91/\",\n            \"to_number\": \"19352326448\",\n            \"total_amount\": \"0.00000\",\n            \"total_rate\": \"0.00350\",\n            \"units\": 1\n        },\n        {\n            \"error_code\": \"200\",\n            \"from_number\": \"18552828641\",\n            \"message_direction\": \"outbound\",\n            \"message_state\": \"failed\",\n            \"message_time\": \"2016-08-17 21:22:36+05:30\",\n            \"message_type\": \"sms\",\n            \"message_uuid\": \"2a340179-e8a9-4b1d-ae2c-9f346e7b6d7d\",\n            \"resource_uri\": \"/v1/Account/{auth_id}/Message/2a340179-e8a9-4b1d-ae2c-9f346e7b6d7d/\",\n            \"to_number\": \"19352326448\",\n            \"total_amount\": \"0.00000\",\n            \"total_rate\": \"0.00350\",\n            \"units\": 1\n        }\n    ]\n}"
    }
  ]
}