Chilkat Online Tools

Android / Salesforce Platform APIs / Get Tooling Metadata SObject

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;

    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken("<access_token>");

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = http.QuickGetSb("https://domain.com/services/data/v{{version}}/tooling/sobjects/:SOBJECT_API_NAME",sbResponseBody);
    if (success == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    CkJsonObject jResp = new CkJsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    Log.i(TAG, "Response Body:");
    Log.i(TAG, jResp.emit());

    int respStatusCode = http.get_LastStatus();
    Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode));
    if (respStatusCode >= 400) {
        Log.i(TAG, "Response Header:");
        Log.i(TAG, http.lastHeader());
        Log.i(TAG, "Failed.");
        return;
        }

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

    // {
    //   "objectDescribe": {
    //     "activateable": false,
    //     "associateEntityType": null,
    //     "associateParentEntity": null,
    //     "createable": true,
    //     "custom": false,
    //     "customSetting": false,
    //     "deepCloneable": false,
    //     "deletable": true,
    //     "deprecatedAndHidden": false,
    //     "feedEnabled": false,
    //     "hasSubtypes": false,
    //     "isInterface": false,
    //     "isSubtype": false,
    //     "keyPrefix": "01p",
    //     "label": "Apex Class",
    //     "labelPlural": "Apex Classes",
    //     "layoutable": true,
    //     "mergeable": false,
    //     "mruEnabled": true,
    //     "name": "ApexClass",
    //     "queryable": true,
    //     "replicateable": true,
    //     "retrieveable": true,
    //     "searchable": true,
    //     "triggerable": false,
    //     "undeletable": false,
    //     "updateable": true,
    //     "urls": {
    //       "compactLayouts": "/services/data/v59.0/tooling/sobjects/ApexClass/describe/compactLayouts",
    //       "rowTemplate": "/services/data/v59.0/tooling/sobjects/ApexClass/{ID}",
    //       "describe": "/services/data/v59.0/tooling/sobjects/ApexClass/describe",
    //       "layouts": "/services/data/v59.0/tooling/sobjects/ApexClass/describe/layouts",
    //       "sobject": "/services/data/v59.0/tooling/sobjects/ApexClass"
    //     }
    //   },
    //   "recentItems": [
    //   ]
    // }

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

    boolean Activateable = jResp.BoolOf("objectDescribe.activateable");
    String AssociateEntityType = jResp.stringOf("objectDescribe.associateEntityType");
    String AssociateParentEntity = jResp.stringOf("objectDescribe.associateParentEntity");
    boolean Createable = jResp.BoolOf("objectDescribe.createable");
    boolean Custom = jResp.BoolOf("objectDescribe.custom");
    boolean CustomSetting = jResp.BoolOf("objectDescribe.customSetting");
    boolean DeepCloneable = jResp.BoolOf("objectDescribe.deepCloneable");
    boolean Deletable = jResp.BoolOf("objectDescribe.deletable");
    boolean DeprecatedAndHidden = jResp.BoolOf("objectDescribe.deprecatedAndHidden");
    boolean FeedEnabled = jResp.BoolOf("objectDescribe.feedEnabled");
    boolean HasSubtypes = jResp.BoolOf("objectDescribe.hasSubtypes");
    boolean IsInterface = jResp.BoolOf("objectDescribe.isInterface");
    boolean IsSubtype = jResp.BoolOf("objectDescribe.isSubtype");
    String KeyPrefix = jResp.stringOf("objectDescribe.keyPrefix");
    String Label = jResp.stringOf("objectDescribe.label");
    String LabelPlural = jResp.stringOf("objectDescribe.labelPlural");
    boolean Layoutable = jResp.BoolOf("objectDescribe.layoutable");
    boolean Mergeable = jResp.BoolOf("objectDescribe.mergeable");
    boolean MruEnabled = jResp.BoolOf("objectDescribe.mruEnabled");
    String Name = jResp.stringOf("objectDescribe.name");
    boolean Queryable = jResp.BoolOf("objectDescribe.queryable");
    boolean Replicateable = jResp.BoolOf("objectDescribe.replicateable");
    boolean Retrieveable = jResp.BoolOf("objectDescribe.retrieveable");
    boolean Searchable = jResp.BoolOf("objectDescribe.searchable");
    boolean Triggerable = jResp.BoolOf("objectDescribe.triggerable");
    boolean Undeletable = jResp.BoolOf("objectDescribe.undeletable");
    boolean Updateable = jResp.BoolOf("objectDescribe.updateable");
    String CompactLayouts = jResp.stringOf("objectDescribe.urls.compactLayouts");
    String RowTemplate = jResp.stringOf("objectDescribe.urls.rowTemplate");
    String Describe = jResp.stringOf("objectDescribe.urls.describe");
    String Layouts = jResp.stringOf("objectDescribe.urls.layouts");
    String Sobject = jResp.stringOf("objectDescribe.urls.sobject");
    int i = 0;
    int count_i = jResp.SizeOfArray("recentItems");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
        }


  }

  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 -X GET
	-H "Authorization: Bearer <access_token>"
https://domain.com/services/data/v{{version}}/tooling/sobjects/:SOBJECT_API_NAME

Postman Collection Item JSON

{
  "name": "Get Tooling Metadata SObject",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{_endpoint}}/services/data/v{{version}}/tooling/sobjects/:SOBJECT_API_NAME",
      "host": [
        "{{_endpoint}}"
      ],
      "path": [
        "services",
        "data",
        "v{{version}}",
        "tooling",
        "sobjects",
        ":SOBJECT_API_NAME"
      ],
      "variable": [
        {
          "key": "SOBJECT_API_NAME",
          "value": ""
        }
      ]
    }
  },
  "response": [
    {
      "name": "Get Tooling Metadata SObject",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{_endpoint}}/services/data/v{{version}}/tooling/sobjects/:SOBJECT_API_NAME",
          "host": [
            "{{_endpoint}}"
          ],
          "path": [
            "services",
            "data",
            "v{{version}}",
            "tooling",
            "sobjects",
            ":SOBJECT_API_NAME"
          ],
          "variable": [
            {
              "key": "SOBJECT_API_NAME",
              "value": "ApexClass"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Date",
          "value": "Mon, 11 Dec 2023 10:36:20 GMT"
        },
        {
          "key": "Strict-Transport-Security",
          "value": "max-age=63072000; includeSubDomains"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "X-Robots-Tag",
          "value": "none"
        },
        {
          "key": "Cache-Control",
          "value": "no-cache,must-revalidate,max-age=0,no-store,private"
        },
        {
          "key": "Sforce-Limit-Info",
          "value": "api-usage=298/15000"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=UTF-8"
        },
        {
          "key": "Vary",
          "value": "Accept-Encoding"
        },
        {
          "key": "Content-Encoding",
          "value": "gzip"
        },
        {
          "key": "Transfer-Encoding",
          "value": "chunked"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"objectDescribe\": {\n        \"activateable\": false,\n        \"associateEntityType\": null,\n        \"associateParentEntity\": null,\n        \"createable\": true,\n        \"custom\": false,\n        \"customSetting\": false,\n        \"deepCloneable\": false,\n        \"deletable\": true,\n        \"deprecatedAndHidden\": false,\n        \"feedEnabled\": false,\n        \"hasSubtypes\": false,\n        \"isInterface\": false,\n        \"isSubtype\": false,\n        \"keyPrefix\": \"01p\",\n        \"label\": \"Apex Class\",\n        \"labelPlural\": \"Apex Classes\",\n        \"layoutable\": true,\n        \"mergeable\": false,\n        \"mruEnabled\": true,\n        \"name\": \"ApexClass\",\n        \"queryable\": true,\n        \"replicateable\": true,\n        \"retrieveable\": true,\n        \"searchable\": true,\n        \"triggerable\": false,\n        \"undeletable\": false,\n        \"updateable\": true,\n        \"urls\": {\n            \"compactLayouts\": \"/services/data/v59.0/tooling/sobjects/ApexClass/describe/compactLayouts\",\n            \"rowTemplate\": \"/services/data/v59.0/tooling/sobjects/ApexClass/{ID}\",\n            \"describe\": \"/services/data/v59.0/tooling/sobjects/ApexClass/describe\",\n            \"layouts\": \"/services/data/v59.0/tooling/sobjects/ApexClass/describe/layouts\",\n            \"sobject\": \"/services/data/v59.0/tooling/sobjects/ApexClass\"\n        }\n    },\n    \"recentItems\": []\n}"
    }
  ]
}