Chilkat Online Tools

Android / Braze Endpoints / Segment Analytics

Back to Collection Items

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    CkHttp http = new CkHttp();
    boolean success;

    CkJsonObject queryParams = new CkJsonObject();
    queryParams.UpdateString("segment_id","{{segment_identifier}}");
    queryParams.UpdateInt("length",14);
    queryParams.UpdateString("ending_at","2018-06-27T23:59:59-5:00");

    // Adds the "Authorization: Bearer {{api_key}}" header.
    http.put_AuthToken("{{api_key}}");

    CkHttpResponse resp = http.QuickRequestParams("GET","https://rest.iad-01.braze.com/segments/data_series",queryParams);
    if (http.get_LastMethodSuccess() == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    Log.i(TAG, String.valueOf(resp.get_StatusCode()));
    Log.i(TAG, resp.bodyStr());


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

Curl Command

curl -G -d "segment_id=%7B%7Bsegment_identifier%7D%7D"
	-d "length=14"
	-d "ending_at=2018-06-27T23%3A59%3A59-5%3A00"
	-H "Authorization: Bearer {{api_key}}"
https://rest.iad-01.braze.com/segments/data_series

Postman Collection Item JSON

{
  "name": "Segment Analytics",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{api_key}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "https://{{instance_url}}/segments/data_series?segment_id={{segment_identifier}}&length=14&ending_at=2018-06-27T23:59:59-5:00",
      "protocol": "https",
      "host": [
        "{{instance_url}}"
      ],
      "path": [
        "segments",
        "data_series"
      ],
      "query": [
        {
          "key": "segment_id",
          "value": "{{segment_identifier}}",
          "description": "(Required) String\n\nSegment API identifier."
        },
        {
          "key": "length",
          "value": "14",
          "description": "(Required) Integer\n\nMax number of days before `ending_at` to include in the returned series - must be between 1 and 100 inclusive."
        },
        {
          "key": "ending_at",
          "value": "2018-06-27T23:59:59-5:00",
          "description": "(Optional) DateTime (ISO 8601 string)\n\nPoint in time when the data series should end - defaults to time of the request."
        }
      ]
    },
    "description": "This endpoint allows you to retrieve a daily series of the size of a segment over time for a segment.\n\n### Request Components\n- [Segment Identifier](https://www.braze.com/docs/api/identifier_types/)\n\n## Response\n\n```json\nContent-Type: application/json\nAuthorization: Bearer YOUR-REST-API-KEY\n{\n    \"message\": (required, string) the status of the export, returns 'success' when completed without errors,\n    \"data\" : [\n        {\n            \"time\" : (string) date as ISO 8601 date,\n            \"size\" : (int) size of the segment on that date\n        },\n        ...\n    ]\n}\n```"
  },
  "response": [
  ]
}