Chilkat Online Tools

Go / Support API / Bulk Unregister Push Notification Devices

Back to Collection Items

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

    http := chilkat.NewHttp()
    var success bool

    http.SetBasicAuth(true)
    http.SetLogin("login")
    http.SetPassword("password")

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {}

    json := chilkat.NewJsonObject()

    http.SetRequestHeader("Content-Type","application/json")
    http.SetRequestHeader("Accept","application/json")

    resp := http.PostJson3("https://example.zendesk.com/api/v2/push_notification_devices/destroy_many","application/json",json)
    if http.LastMethodSuccess() == false {
        fmt.Println(http.LastErrorText())
        http.DisposeHttp()
        json.DisposeJsonObject()
        return
    }

    sbResponseBody := chilkat.NewStringBuilder()
    resp.GetBodySb(sbResponseBody)

    jResp := chilkat.NewJsonObject()
    jResp.LoadSb(sbResponseBody)
    jResp.SetEmitCompact(false)

    fmt.Println("Response Body:")
    fmt.Println(*jResp.Emit())

    respStatusCode := resp.StatusCode()
    fmt.Println("Response Status Code = ", respStatusCode)
    if respStatusCode >= 400 {
        fmt.Println("Response Header:")
        fmt.Println(resp.Header())
        fmt.Println("Failed.")
        resp.DisposeHttpResponse()
        http.DisposeHttp()
        json.DisposeJsonObject()
        sbResponseBody.DisposeStringBuilder()
        jResp.DisposeJsonObject()
        return
    }

    resp.DisposeHttpResponse()

    http.DisposeHttp()
    json.DisposeJsonObject()
    sbResponseBody.DisposeStringBuilder()
    jResp.DisposeJsonObject()

Curl Command

curl  -u login:password -X POST
	-H "Content-Type: application/json"
	-H "Accept: application/json"
	-d '{}'
https://example.zendesk.com/api/v2/push_notification_devices/destroy_many

Postman Collection Item JSON

{
  "name": "Bulk Unregister Push Notification Devices",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{}",
      "options": {
        "raw": {
          "headerFamily": "json",
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{baseUrl}}/api/v2/push_notification_devices/destroy_many",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "push_notification_devices",
        "destroy_many"
      ]
    },
    "description": "Unregisters the mobile devices that are receiving push notifications. Specify the devices as an array of mobile device tokens.\n\n#### Allowed for\n\n* Admins"
  },
  "response": [
    {
      "name": "Successful response",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v2/push_notification_devices/destroy_many",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "push_notification_devices",
            "destroy_many"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "<string>"
    }
  ]
}