Accessing UDG APIs

Hello community,

I’m setting up a simple UDG API to do a POC and I can’t seem to access it via Postman or any other tool. On the playground it works perfectly fine but I’m wondering how can I make an external request to the API?

I have Tyk setup on my local machine with the Dashboard UI, and I’m able to invoke the other endpoints (e.g. Virtual Endpoints) via Postman.

So far I’ve tried GET/POST request to http://localhost:8080/udg and http://localhost:8080/udg/ but their response are 404 “Not Found”

Edit: GET/POST to http://localhost:8080/udg/ returns a 400 status code with the message “the provided request is empty”

Here is the UDG that I’ve setup:

{
  "created_at": "2023-03-17T05:54:32Z",
  "api_model": {},
  "api_definition": {
    "api_id": "a509c429c86147b467df5a2d721bf7d8",
    "jwt_issued_at_validation_skew": 0,
    "upstream_certificates": {},
    "use_keyless": true,
    "enable_coprocess_auth": false,
    "base_identity_provided_by": "",
    "custom_middleware": {
      "pre": [],
      "post": [],
      "post_key_auth": [],
      "auth_check": {
        "name": "",
        "path": "",
        "require_session": false,
        "raw_body_only": false
      },
      "response": [],
      "driver": "",
      "id_extractor": {
        "extract_from": "",
        "extract_with": "",
        "extractor_config": {}
      }
    },
    "disable_quota": false,
    "custom_middleware_bundle": "",
    "cache_options": {
      "cache_timeout": 60,
      "enable_cache": true,
      "cache_all_safe_requests": false,
      "cache_response_codes": [],
      "enable_upstream_cache_control": false,
      "cache_control_ttl_header": "",
      "cache_by_headers": []
    },
    "enable_ip_blacklisting": false,
    "tag_headers": [],
    "jwt_scope_to_policy_mapping": {},
    "tags_disabled": false,
    "pinned_public_keys": {},
    "expire_analytics_after": 0,
    "domain": "",
    "openid_options": {
      "providers": [],
      "segregate_by_client": false
    },
    "jwt_policy_field_name": "",
    "enable_proxy_protocol": false,
    "jwt_default_policies": [],
    "active": true,
    "jwt_expires_at_validation_skew": 0,
    "config_data": {},
    "notifications": {
      "shared_secret": "",
      "oauth_on_keychange_url": ""
    },
    "jwt_client_base_field": "",
    "auth": {
      "disable_header": false,
      "auth_header_name": "Authorization",
      "cookie_name": "",
      "name": "",
      "validate_signature": false,
      "use_param": false,
      "signature": {
        "algorithm": "",
        "header": "",
        "use_param": false,
        "param_name": "",
        "secret": "",
        "allowed_clock_skew": 0,
        "error_code": 0,
        "error_message": ""
      },
      "use_cookie": false,
      "param_name": "",
      "use_certificate": false
    },
    "check_host_against_uptime_tests": false,
    "auth_provider": {
      "name": "",
      "storage_engine": "",
      "meta": {}
    },
    "blacklisted_ips": [],
    "graphql": {
      "schema": "type Query {\n  users(id: Int): User\n}\n\ntype User {\n  id: Int\n  name: String\n  username: String\n  email: String\n  posts(title: String): [Post]\n}\n\ntype Post {\n  id: Int\n  userId: Int\n  title: String\n  body: String\n}\n\ntype Mutation {\n  default: String\n}",
      "enabled": true,
      "engine": {
        "field_configs": [
          {
            "type_name": "User",
            "field_name": "posts",
            "disable_default_mapping": true,
            "path": [
              ""
            ]
          },
          {
            "type_name": "Query",
            "field_name": "users",
            "disable_default_mapping": true,
            "path": [
              ""
            ]
          }
        ],
        "data_sources": [
          {
            "kind": "REST",
            "name": "getPostsByUserId",
            "internal": false,
            "root_fields": [
              {
                "type": "User",
                "fields": [
                  "posts"
                ]
              }
            ],
            "config": {
              "url": "https://jsonplaceholder.typicode.com/posts?userId={{.object.id}}",
              "method": "GET",
              "body": "",
              "headers": {},
              "default_type_name": "Post"
            }
          },
          {
            "kind": "REST",
            "name": "getUsers",
            "internal": false,
            "root_fields": [
              {
                "type": "Query",
                "fields": [
                  "users"
                ]
              }
            ],
            "config": {
              "url": "https://jsonplaceholder.typicode.com/users/{{.arguments.id}}",
              "method": "GET",
              "body": "",
              "headers": {},
              "default_type_name": "HttpBin"
            }
          }
        ]
      },
      "type_field_configurations": [],
      "execution_mode": "executionEngine",
      "proxy": {
        "auth_headers": {}
      },
      "subgraph": {
        "sdl": ""
      },
      "supergraph": {
        "subgraphs": [],
        "merged_sdl": "",
        "global_headers": {},
        "disable_query_batching": false
      },
      "version": "2",
      "playground": {
        "enabled": false,
        "path": "/playground"
      },
      "last_schema_update": "2023-03-17T06:29:01.956Z"
    },
    "hmac_allowed_clock_skew": -1,
    "dont_set_quota_on_create": false,
    "uptime_tests": {
      "check_list": [],
      "config": {
        "expire_utime_after": 0,
        "service_discovery": {
          "use_discovery_service": false,
          "query_endpoint": "",
          "use_nested_query": false,
          "parent_data_path": "",
          "data_path": "",
          "cache_timeout": 60
        },
        "recheck_wait": 0
      }
    },
    "enable_jwt": false,
    "do_not_track": false,
    "name": "UDG",
    "slug": "udg",
    "is_oas": false,
    "analytics_plugin": {
      "enable": false,
      "plugin_path": "",
      "func_name": ""
    },
    "oauth_meta": {
      "allowed_access_types": [],
      "allowed_authorize_types": [],
      "auth_login_redirect": ""
    },
    "CORS": {
      "enable": false,
      "max_age": 24,
      "allow_credentials": false,
      "exposed_headers": [],
      "allowed_headers": [
        "Origin",
        "Accept",
        "Content-Type",
        "X-Requested-With",
        "Authorization"
      ],
      "options_passthrough": false,
      "debug": false,
      "allowed_origins": [
        "*"
      ],
      "allowed_methods": [
        "GET",
        "POST",
        "HEAD"
      ]
    },
    "event_handlers": {
      "events": {}
    },
    "proxy": {
      "target_url": "",
      "service_discovery": {
        "endpoint_returns_list": false,
        "cache_timeout": 0,
        "parent_data_path": "",
        "query_endpoint": "",
        "use_discovery_service": false,
        "_sd_show_port_path": false,
        "target_path": "",
        "use_target_list": false,
        "use_nested_query": false,
        "data_path": "",
        "port_data_path": ""
      },
      "check_host_against_uptime_tests": false,
      "transport": {
        "ssl_insecure_skip_verify": false,
        "ssl_min_version": 0,
        "proxy_url": "",
        "ssl_ciphers": []
      },
      "target_list": [],
      "preserve_host_header": false,
      "strip_listen_path": true,
      "enable_load_balancing": false,
      "listen_path": "/udg/",
      "disable_strip_slash": true
    },
    "expiration": "",
    "client_certificates": [],
    "use_basic_auth": false,
    "version_data": {
      "not_versioned": true,
      "default_version": "",
      "versions": {
        "Default": {
          "name": "Default",
          "expires": "",
          "paths": {
            "ignored": [],
            "white_list": [],
            "black_list": []
          },
          "use_extended_paths": true,
          "extended_paths": {
            "ignored": [],
            "white_list": [],
            "black_list": [],
            "transform": [],
            "transform_response": [],
            "transform_jq": [],
            "transform_jq_response": [],
            "transform_headers": [],
            "transform_response_headers": [],
            "hard_timeouts": [],
            "circuit_breakers": [],
            "url_rewrites": [],
            "virtual": [],
            "size_limits": [],
            "method_transforms": [],
            "track_endpoints": [],
            "do_not_track_endpoints": [],
            "validate_json": [],
            "internal": []
          },
          "global_headers": {},
          "global_headers_remove": [],
          "global_response_headers": {},
          "global_response_headers_remove": [],
          "ignore_endpoint_case": false,
          "global_size_limit": 0,
          "override_target": ""
        }
      }
    },
    "jwt_scope_claim_name": "",
    "use_standard_auth": false,
    "session_lifetime": 0,
    "hmac_allowed_algorithms": [],
    "disable_rate_limit": false,
    "definition": {
      "enabled": false,
      "name": "",
      "default": "",
      "location": "header",
      "key": "x-api-version",
      "strip_path": false,
      "strip_versioning_data": false,
      "versions": {}
    },
    "use_oauth2": false,
    "jwt_source": "",
    "jwt_signing_method": "",
    "session_lifetime_respects_key_expiration": false,
    "jwt_not_before_validation_skew": 0,
    "use_go_plugin_auth": false,
    "jwt_identity_base_field": "",
    "allowed_ips": [],
    "request_signing": {
      "is_enabled": false,
      "secret": "",
      "key_id": "",
      "algorithm": "",
      "header_list": [],
      "certificate_id": "",
      "signature_header": ""
    },
    "org_id": "64140088f9f55c0001d4f8c1",
    "domain_disabled": false,
    "enable_ip_whitelisting": false,
    "global_rate_limit": {
      "rate": 0,
      "per": 0
    },
    "protocol": "",
    "enable_context_vars": false,
    "tags": [],
    "basic_auth": {
      "disable_caching": false,
      "cache_ttl": 0,
      "extract_from_body": false,
      "body_user_regexp": "",
      "body_password_regexp": ""
    },
    "listen_port": 0,
    "session_provider": {
      "name": "",
      "storage_engine": "",
      "meta": {}
    },
    "auth_configs": {
      "authToken": {
        "disable_header": false,
        "auth_header_name": "Authorization",
        "cookie_name": "",
        "name": "",
        "validate_signature": false,
        "use_param": false,
        "signature": {
          "algorithm": "",
          "header": "",
          "use_param": false,
          "param_name": "",
          "secret": "",
          "allowed_clock_skew": 0,
          "error_code": 0,
          "error_message": ""
        },
        "use_cookie": false,
        "param_name": "",
        "use_certificate": false
      },
      "basic": {
        "disable_header": false,
        "auth_header_name": "Authorization",
        "cookie_name": "",
        "name": "",
        "validate_signature": false,
        "use_param": false,
        "signature": {
          "algorithm": "",
          "header": "",
          "use_param": false,
          "param_name": "",
          "secret": "",
          "allowed_clock_skew": 0,
          "error_code": 0,
          "error_message": ""
        },
        "use_cookie": false,
        "param_name": "",
        "use_certificate": false
      },
      "coprocess": {
        "disable_header": false,
        "auth_header_name": "Authorization",
        "cookie_name": "",
        "name": "",
        "validate_signature": false,
        "use_param": false,
        "signature": {
          "algorithm": "",
          "header": "",
          "use_param": false,
          "param_name": "",
          "secret": "",
          "allowed_clock_skew": 0,
          "error_code": 0,
          "error_message": ""
        },
        "use_cookie": false,
        "param_name": "",
        "use_certificate": false
      },
      "hmac": {
        "disable_header": false,
        "auth_header_name": "Authorization",
        "cookie_name": "",
        "name": "",
        "validate_signature": false,
        "use_param": false,
        "signature": {
          "algorithm": "",
          "header": "",
          "use_param": false,
          "param_name": "",
          "secret": "",
          "allowed_clock_skew": 0,
          "error_code": 0,
          "error_message": ""
        },
        "use_cookie": false,
        "param_name": "",
        "use_certificate": false
      },
      "jwt": {
        "disable_header": false,
        "auth_header_name": "Authorization",
        "cookie_name": "",
        "name": "",
        "validate_signature": false,
        "use_param": false,
        "signature": {
          "algorithm": "",
          "header": "",
          "use_param": false,
          "param_name": "",
          "secret": "",
          "allowed_clock_skew": 0,
          "error_code": 0,
          "error_message": ""
        },
        "use_cookie": false,
        "param_name": "",
        "use_certificate": false
      },
      "oauth": {
        "disable_header": false,
        "auth_header_name": "Authorization",
        "cookie_name": "",
        "name": "",
        "validate_signature": false,
        "use_param": false,
        "signature": {
          "algorithm": "",
          "header": "",
          "use_param": false,
          "param_name": "",
          "secret": "",
          "allowed_clock_skew": 0,
          "error_code": 0,
          "error_message": ""
        },
        "use_cookie": false,
        "param_name": "",
        "use_certificate": false
      },
      "oidc": {
        "disable_header": false,
        "auth_header_name": "Authorization",
        "cookie_name": "",
        "name": "",
        "validate_signature": false,
        "use_param": false,
        "signature": {
          "algorithm": "",
          "header": "",
          "use_param": false,
          "param_name": "",
          "secret": "",
          "allowed_clock_skew": 0,
          "error_code": 0,
          "error_message": ""
        },
        "use_cookie": false,
        "param_name": "",
        "use_certificate": false
      }
    },
    "strip_auth_data": false,
    "certificate_pinning_disabled": false,
    "id": "64140098f9f55c0001d4f8c3",
    "upstream_certificates_disabled": false,
    "certificates": [],
    "enable_signature_checking": false,
    "use_openid": false,
    "internal": false,
    "jwt_skip_kid": false,
    "enable_batch_request_support": false,
    "enable_detailed_recording": false,
    "scopes": {
      "jwt": {
        "scope_claim_name": "",
        "scope_to_policy": {}
      },
      "oidc": {
        "scope_claim_name": "",
        "scope_to_policy": {}
      }
    },
    "response_processors": [],
    "use_mutual_tls_auth": false
  },
  "hook_references": [],
  "is_site": false,
  "sort_by": 0,
  "user_group_owners": [],
  "user_owners": []
}

Tyk version: 4.2.0

Thank you

Hi @jeremy,

Welcome to the community :partying_face:

Please set "track_404_logs": true and "log_level": "debug" in your tyk.conf file and try again.
Please share the gateway logs when you call the API

1 Like

Hello @Ubong, thanks for the reply. Upon restarting the docker containers, the endpoint http://localhost:8080/udg/ now responds a 400 status with the message “the provided request is empty”. Here are the gateway logs:

tyk-gateway    | time="Mar 21 03:27:09" level=debug msg=Started api_id=a509c429c86147b467df5a2d721bf7d8 api_name=UDG mw=VersionCheck org_id=64140088f9f55c0001d4f8c1 origin=192.168.208.1 path="/udg/" ts=1679369229431730000
tyk-gateway    | time="Mar 21 03:27:09" level=debug msg=Finished api_id=a509c429c86147b467df5a2d721bf7d8 api_name=UDG code=200 mw=VersionCheck ns=153000 org_id=64140088f9f55c0001d4f8c1 origin=192.168.208.1 path="/udg/"
tyk-gateway    | time="Mar 21 03:27:09" level=debug msg=Started api_id=a509c429c86147b467df5a2d721bf7d8 api_name=UDG mw=RateCheckMW org_id=64140088f9f55c0001d4f8c1 origin=192.168.208.1 path="/udg/" ts=1679369229432096000
tyk-gateway    | time="Mar 21 03:27:09" level=debug msg=Finished api_id=a509c429c86147b467df5a2d721bf7d8 api_name=UDG code=200 mw=RateCheckMW ns=229000 org_id=64140088f9f55c0001d4f8c1 origin=192.168.208.1 path="/udg/"
tyk-gateway    | time="Mar 21 03:27:09" level=debug msg=Started api_id=a509c429c86147b467df5a2d721bf7d8 api_name=UDG mw=OrganizationMonitor org_id=64140088f9f55c0001d4f8c1 origin=192.168.208.1 path="/udg/" ts=1679369229432460000
tyk-gateway    | time="Mar 21 03:27:09" level=debug msg="Could not get session detail, key not found" err="key not found" inbound-key="****f8c1" prefix=auth-mgr
tyk-gateway    | time="Mar 21 03:27:09" level=debug msg=Finished api_id=a509c429c86147b467df5a2d721bf7d8 api_name=UDG code=200 mw=OrganizationMonitor ns=2954000 org_id=64140088f9f55c0001d4f8c1 origin=192.168.208.1 path="/udg/"
tyk-gateway    | time="Mar 21 03:27:09" level=debug msg=Started api_id=a509c429c86147b467df5a2d721bf7d8 api_name=UDG mw=GraphQLMiddleware org_id=64140088f9f55c0001d4f8c1 origin=192.168.208.1 path="/udg/" ts=1679369229436503000
tyk-gateway    | time="Mar 21 03:27:09" level=debug msg="Error while unmarshalling GraphQL request: 'the provided request is empty'" api_id=a509c429c86147b467df5a2d721bf7d8 api_name=UDG mw=GraphQLMiddleware org_id=64140088f9f55c0001d4f8c1 origin=192.168.208.1 path="/udg/"
tyk-gateway    | time="Mar 21 03:27:09" level=debug msg="Checking: 64140088f9f55c0001d4f8c1" api_id=a509c429c86147b467df5a2d721bf7d8 api_name=UDG mw=GraphQLMiddleware org_id=64140088f9f55c0001d4f8c1 origin=192.168.208.1 path="/udg/"
tyk-gateway    | time="Mar 21 03:27:09" level=debug msg="Could not get session detail, key not found" err="key not found" inbound-key="****f8c1" prefix=auth-mgr
tyk-gateway    | time="Mar 21 03:27:09" level=debug msg="no cached entry found, returning 7 days" api_id=a509c429c86147b467df5a2d721bf7d8 api_name=UDG mw=GraphQLMiddleware org_id=64140088f9f55c0001d4f8c1 origin=192.168.208.1 path="/udg/"
tyk-gateway    | time="Mar 21 03:27:09" level=debug msg=Finished api_id=a509c429c86147b467df5a2d721bf7d8 api_name=UDG code=400 error="the provided request is empty" mw=GraphQLMiddleware ns=23137000 org_id=64140088f9f55c0001d4f8c1 origin=192.168.208.1 path="/udg/"

Is this related to setting up an API key? The auth configuration of this UDG API is set to Open(keyless).

Hey @jeremy,

No, it’s not.
It’s probably more related to how you’re calling the API.
See here for calling GraphQL API with Postman.

You can copy/paste the query from the playground to the query tab in postman.

That solves my issue, thanks @Ubong!