Chilkat Online Tools

PureBasic / Marketplacer SELLER API / Schema Introspection

Back to Collection Items

IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"

Procedure ChilkatExample()

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

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    CkHttp::setCkBasicAuth(http, 1)
    CkHttp::setCkLogin(http, "{{username}}")
    CkHttp::setCkPassword(http, "{{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.

    ; {
    ;   "query": "query IntrospectionQuery {\n      __schema {\n        \n        queryType { name }\n        mutationType { name }\n        subscriptionType { name }\n        types {\n          ...FullType\n        }\n        directives {\n          name\n          description\n          \n          locations\n          args {\n            ...InputValue\n          }\n        }\n      }\n    }\n\n    fragment 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    }\n\n    fragment InputValue on __InputValue {\n      name\n      description\n      type { ...TypeRef }\n      defaultValue\n    }\n\n    fragment 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            ofType {\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          }\n        }\n      }\n    }",
    ;   "variables": ""
    ; }

    json.i = CkJsonObject::ckCreate()
    If json.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckUpdateString(json,"query","query IntrospectionQuery {" + Chr(10) + "      __schema {" + Chr(10) + "        " + Chr(10) + "        queryType { name }" + Chr(10) + "        mutationType { name }" + Chr(10) + "        subscriptionType { name }" + Chr(10) + "        types {" + Chr(10) + "          ...FullType" + Chr(10) + "        }" + Chr(10) + "        directives {" + Chr(10) + "          name" + Chr(10) + "          description" + Chr(10) + "          " + Chr(10) + "          locations" + Chr(10) + "          args {" + Chr(10) + "            ...InputValue" + Chr(10) + "          }" + Chr(10) + "        }" + Chr(10) + "      }" + Chr(10) + "    }" + Chr(10) + Chr(10) + "    fragment FullType on __Type {" + Chr(10) + "      kind" + Chr(10) + "      name" + Chr(10) + "      description" + Chr(10) + "      fields(includeDeprecated: true) {" + Chr(10) + "        name" + Chr(10) + "        description" + Chr(10) + "        args {" + Chr(10) + "          ...InputValue" + Chr(10) + "        }" + Chr(10) + "        type {" + Chr(10) + "          ...TypeRef" + Chr(10) + "        }" + Chr(10) + "        isDeprecated" + Chr(10) + "        deprecationReason" + Chr(10) + "      }" + Chr(10) + "      inputFields {" + Chr(10) + "        ...InputValue" + Chr(10) + "      }" + Chr(10) + "      interfaces {" + Chr(10) + "        ...TypeRef" + Chr(10) + "      }" + Chr(10) + "      enumValues(includeDeprecated: true) {" + Chr(10) + "        name" + Chr(10) + "        description" + Chr(10) + "        isDeprecated" + Chr(10) + "        deprecationReason" + Chr(10) + "      }" + Chr(10) + "      possibleTypes {" + Chr(10) + "        ...TypeRef" + Chr(10) + "      }" + Chr(10) + "    }" + Chr(10) + Chr(10) + "    fragment InputValue on __InputValue {" + Chr(10) + "      name" + Chr(10) + "      description" + Chr(10) + "      type { ...TypeRef }" + Chr(10) + "      defaultValue" + Chr(10) + "    }" + Chr(10) + Chr(10) + "    fragment TypeRef on __Type {" + Chr(10) + "      kind" + Chr(10) + "      name" + Chr(10) + "      ofType {" + Chr(10) + "        kind" + Chr(10) + "        name" + Chr(10) + "        ofType {" + Chr(10) + "          kind" + Chr(10) + "          name" + Chr(10) + "          ofType {" + Chr(10) + "            kind" + Chr(10) + "            name" + Chr(10) + "            ofType {" + Chr(10) + "              kind" + Chr(10) + "              name" + Chr(10) + "              ofType {" + Chr(10) + "                kind" + Chr(10) + "                name" + Chr(10) + "                ofType {" + Chr(10) + "                  kind" + Chr(10) + "                  name" + Chr(10) + "                  ofType {" + Chr(10) + "                    kind" + Chr(10) + "                    name" + Chr(10) + "                  }" + Chr(10) + "                }" + Chr(10) + "              }" + Chr(10) + "            }" + Chr(10) + "          }" + Chr(10) + "        }" + Chr(10) + "      }" + Chr(10) + "    }")
    CkJsonObject::ckUpdateString(json,"variables","")

    CkHttp::ckSetRequestHeader(http,"Content-Type","application/json")
    CkHttp::ckSetRequestHeader(http,"MARKETPLACER-API-KEY","{{api_key}}")

    resp.i = CkHttp::ckPostJson3(http,"https://bestfriendbazaar.com/graphql","application/json",json)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(json)
        ProcedureReturn
    EndIf

    Debug Str(CkHttpResponse::ckStatusCode(resp))
    Debug CkHttpResponse::ckBodyStr(resp)
    CkHttpResponse::ckDispose(resp)



    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(json)


    ProcedureReturn
EndProcedure

Curl Command

curl -X POST
	-u '{{username}}:{{password}}'
	-H "MARKETPLACER-API-KEY: {{api_key}}"
	-H "Content-Type: application/json"
	--data-raw '{"query":"query IntrospectionQuery {\n      __schema {\n        \n        queryType { name }\n        mutationType { name }\n        subscriptionType { name }\n        types {\n          ...FullType\n        }\n        directives {\n          name\n          description\n          \n          locations\n          args {\n            ...InputValue\n          }\n        }\n      }\n    }\n\n    fragment 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    }\n\n    fragment InputValue on __InputValue {\n      name\n      description\n      type { ...TypeRef }\n      defaultValue\n    }\n\n    fragment 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            ofType {\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          }\n        }\n      }\n    }","variables":""}'
https://bestfriendbazaar.com/graphql

Postman Collection Item JSON

{
  "name": "Schema Introspection",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "MARKETPLACER-API-KEY",
        "value": "{{api_key}}",
        "type": "text"
      },
      {
        "key": "Content-Type",
        "value": "application/json",
        "type": "text"
      }
    ],
    "body": {
      "mode": "graphql",
      "graphql": {
        "query": "query IntrospectionQuery {\n      __schema {\n        \n        queryType { name }\n        mutationType { name }\n        subscriptionType { name }\n        types {\n          ...FullType\n        }\n        directives {\n          name\n          description\n          \n          locations\n          args {\n            ...InputValue\n          }\n        }\n      }\n    }\n\n    fragment 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    }\n\n    fragment InputValue on __InputValue {\n      name\n      description\n      type { ...TypeRef }\n      defaultValue\n    }\n\n    fragment 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            ofType {\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          }\n        }\n      }\n    }",
        "variables": ""
      }
    },
    "url": {
      "raw": "{{base_url}}",
      "host": [
        "{{base_url}}"
      ],
      "path": null
    },
    "description": null
  },
  "response": [
  ]
}