Chilkat Online Tools

VB.NET / Salesforce Platform APIs / Introspection Query

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 Chilkat.Http
Dim success As Boolean

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

' The following JSON is sent in the request body.

' {
'   "query": "query IntrospectionQuery {\n  __schema {\n    queryType {\n      name\n    }\n    mutationType {\n      name\n    }\n    subscriptionType {\n      name\n    }\n    types {\n      ...FullType\n    }\n    directives {\n      name\n      description\n      args {\n        ...InputValue\n      }\n      onOperation\n      onFragment\n      onField\n      locations\n    }\n  }\n}\nfragment FullType on __Type {\n  kind\n  name\n  description\n  fields(includeDeprecated: true) {\n    name\n    description\n    args {\n      ...InputValue\n    }\n    type {\n      ...TypeRef\n    }\n    isDeprecated\n    deprecationReason\n  }\n  inputFields {\n    ...InputValue\n  }\n  interfaces {\n    ...TypeRef\n  }\n  enumValues(includeDeprecated: true) {\n    name\n    description\n    isDeprecated\n    deprecationReason\n  }\n  possibleTypes {\n    ...TypeRef\n  }\n}\nfragment InputValue on __InputValue {\n  name\n  description\n  type {\n    ...TypeRef\n  }\n  defaultValue\n}\nfragment TypeRef on __Type {\n  kind\n  name\n  ofType {\n    kind\n    name\n    ofType {\n      kind\n      name\n      ofType {\n        kind\n        name\n      }\n    }\n  }\n}\n",
'   "variables": ""
' }

Dim json As New Chilkat.JsonObject
json.UpdateString("query","query IntrospectionQuery {" & vbLf & "  __schema {" & vbLf & "    queryType {" & vbLf & "      name" & vbLf & "    }" & vbLf & "    mutationType {" & vbLf & "      name" & vbLf & "    }" & vbLf & "    subscriptionType {" & vbLf & "      name" & vbLf & "    }" & vbLf & "    types {" & vbLf & "      ...FullType" & vbLf & "    }" & vbLf & "    directives {" & vbLf & "      name" & vbLf & "      description" & vbLf & "      args {" & vbLf & "        ...InputValue" & vbLf & "      }" & vbLf & "      onOperation" & vbLf & "      onFragment" & vbLf & "      onField" & vbLf & "      locations" & vbLf & "    }" & vbLf & "  }" & vbLf & "}" & vbLf & "fragment FullType on __Type {" & vbLf & "  kind" & vbLf & "  name" & vbLf & "  description" & vbLf & "  fields(includeDeprecated: true) {" & vbLf & "    name" & vbLf & "    description" & vbLf & "    args {" & vbLf & "      ...InputValue" & vbLf & "    }" & vbLf & "    type {" & vbLf & "      ...TypeRef" & vbLf & "    }" & vbLf & "    isDeprecated" & vbLf & "    deprecationReason" & vbLf & "  }" & vbLf & "  inputFields {" & vbLf & "    ...InputValue" & vbLf & "  }" & vbLf & "  interfaces {" & vbLf & "    ...TypeRef" & vbLf & "  }" & vbLf & "  enumValues(includeDeprecated: true) {" & vbLf & "    name" & vbLf & "    description" & vbLf & "    isDeprecated" & vbLf & "    deprecationReason" & vbLf & "  }" & vbLf & "  possibleTypes {" & vbLf & "    ...TypeRef" & vbLf & "  }" & vbLf & "}" & vbLf & "fragment InputValue on __InputValue {" & vbLf & "  name" & vbLf & "  description" & vbLf & "  type {" & vbLf & "    ...TypeRef" & vbLf & "  }" & vbLf & "  defaultValue" & vbLf & "}" & vbLf & "fragment TypeRef on __Type {" & vbLf & "  kind" & vbLf & "  name" & vbLf & "  ofType {" & vbLf & "    kind" & vbLf & "    name" & vbLf & "    ofType {" & vbLf & "      kind" & vbLf & "      name" & vbLf & "      ofType {" & vbLf & "        kind" & vbLf & "        name" & vbLf & "      }" & vbLf & "    }" & vbLf & "  }" & vbLf & "}" & vbLf)
json.UpdateString("variables","")

' Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = "<access_token>"
http.SetRequestHeader("X-Chatter-Entity-Encoding","false")

Dim resp As Chilkat.HttpResponse = http.PostJson3("https://domain.com/services/data/v{{version}}/graphql","application/json",json)
If (http.LastMethodSuccess = False) Then
    Debug.WriteLine(http.LastErrorText)
    Exit Sub
End If


Debug.WriteLine(resp.StatusCode)
Debug.WriteLine(resp.BodyStr)

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "X-Chatter-Entity-Encoding: false"
	--data-raw '{"query":"query IntrospectionQuery {\n  __schema {\n    queryType {\n      name\n    }\n    mutationType {\n      name\n    }\n    subscriptionType {\n      name\n    }\n    types {\n      ...FullType\n    }\n    directives {\n      name\n      description\n      args {\n        ...InputValue\n      }\n      onOperation\n      onFragment\n      onField\n      locations\n    }\n  }\n}\nfragment FullType on __Type {\n  kind\n  name\n  description\n  fields(includeDeprecated: true) {\n    name\n    description\n    args {\n      ...InputValue\n    }\n    type {\n      ...TypeRef\n    }\n    isDeprecated\n    deprecationReason\n  }\n  inputFields {\n    ...InputValue\n  }\n  interfaces {\n    ...TypeRef\n  }\n  enumValues(includeDeprecated: true) {\n    name\n    description\n    isDeprecated\n    deprecationReason\n  }\n  possibleTypes {\n    ...TypeRef\n  }\n}\nfragment InputValue on __InputValue {\n  name\n  description\n  type {\n    ...TypeRef\n  }\n  defaultValue\n}\nfragment TypeRef on __Type {\n  kind\n  name\n  ofType {\n    kind\n    name\n    ofType {\n      kind\n      name\n      ofType {\n        kind\n        name\n      }\n    }\n  }\n}\n","variables":""}'
https://domain.com/services/data/v{{version}}/graphql

Postman Collection Item JSON

{
  "name": "Introspection Query",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "X-Chatter-Entity-Encoding",
        "value": "false",
        "type": "text"
      }
    ],
    "body": {
      "mode": "graphql",
      "graphql": {
        "query": "query IntrospectionQuery {\n  __schema {\n    queryType {\n      name\n    }\n    mutationType {\n      name\n    }\n    subscriptionType {\n      name\n    }\n    types {\n      ...FullType\n    }\n    directives {\n      name\n      description\n      args {\n        ...InputValue\n      }\n      onOperation\n      onFragment\n      onField\n      locations\n    }\n  }\n}\nfragment FullType on __Type {\n  kind\n  name\n  description\n  fields(includeDeprecated: true) {\n    name\n    description\n    args {\n      ...InputValue\n    }\n    type {\n      ...TypeRef\n    }\n    isDeprecated\n    deprecationReason\n  }\n  inputFields {\n    ...InputValue\n  }\n  interfaces {\n    ...TypeRef\n  }\n  enumValues(includeDeprecated: true) {\n    name\n    description\n    isDeprecated\n    deprecationReason\n  }\n  possibleTypes {\n    ...TypeRef\n  }\n}\nfragment InputValue on __InputValue {\n  name\n  description\n  type {\n    ...TypeRef\n  }\n  defaultValue\n}\nfragment TypeRef on __Type {\n  kind\n  name\n  ofType {\n    kind\n    name\n    ofType {\n      kind\n      name\n      ofType {\n        kind\n        name\n      }\n    }\n  }\n}\n",
        "variables": ""
      }
    },
    "url": {
      "raw": "{{_endpoint}}/services/data/v{{version}}/graphql",
      "host": [
        "{{_endpoint}}"
      ],
      "path": [
        "services",
        "data",
        "v{{version}}",
        "graphql"
      ]
    }
  },
  "response": [
  ]
}