Chilkat Online Tools

SQL Server / Postman API / Fetch User Resource

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', '{{apiKey}}'

    DECLARE @sbResponseBody int
    -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://api.getpostman.com/scim/v2/Users/{{id}}', @sbResponseBody
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END


    EXEC sp_OAGetProperty @http, 'LastStatus', @iTmp0 OUT
    PRINT 'Response status code = ' + @iTmp0
    EXEC sp_OAMethod @sbResponseBody, 'GetAsString', @sTmp0 OUT
    PRINT @sTmp0

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @sbResponseBody


END
GO

Curl Command

curl -X GET
	-H "Authorization: {{apiKey}}"
https://api.getpostman.com/scim/v2/Users/{{id}}

Postman Collection Item JSON

{
  "name": "Fetch User Resource",
  "request": {
    "auth": {
      "type": "noauth"
    },
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "{{apiKey}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "https://api.getpostman.com/scim/v2/Users/{{id}}",
      "protocol": "https",
      "host": [
        "api",
        "getpostman",
        "com"
      ],
      "path": [
        "scim",
        "v2",
        "Users",
        "{{id}}"
      ]
    },
    "description": "Fetches an individual Postman team member's information."
  },
  "response": [
    {
      "name": "200",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "{{apikey}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{url}}/Users/405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "host": [
            "{{url}}"
          ],
          "path": [
            "Users",
            "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99"
          ]
        }
      },
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n    \"schemas\": [\n        \"urn:ietf:params:scim:schemas:core:2.0:User\"\n    ],\n    \"id\": \"405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99\",\n    \"userName\": \"test.user@okta.local\",\n    \"name\": {\n        \"givenName\": \"Test\",\n        \"familyName\": \"User\"\n    },\n    \"externalId\": \"23123123\",\n    \"active\": true,\n    \"meta\": {\n        \"resourceType\": \"User\",\n        \"created\": \"2021-02-22T04:24:13.000Z\",\n        \"lastModified\": \"2021-02-22T04:24:13.000Z\"\n    }\n}"
    },
    {
      "name": "400 - Invalid team",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "{{apiKey}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{url}}/Users/405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "host": [
            "{{url}}"
          ],
          "path": [
            "Users",
            "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n    \"schemas\": [\n        \"urn:ietf:params:scim:api:messages:2.0:Error\"\n    ],\n    \"detail\": \"This Postman team doesn’t exist anymore.\",\n    \"status\": \"400\"\n}"
    },
    {
      "name": "401 - Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "invalidApiKey",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{url}}/Users/405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "host": [
            "{{url}}"
          ],
          "path": [
            "Users",
            "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99"
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n    \"schemas\": [\n        \"urn:ietf:params:scim:api:messages:2.0:Error\"\n    ],\n    \"detail\": \"Unable to access the team. Check if you have entered a valid API key.\",\n    \"status\": \"401\"\n}"
    },
    {
      "name": "403 - Admin team mismatch",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "{{apiKey}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{url}}/Users/405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "host": [
            "{{url}}"
          ],
          "path": [
            "Users",
            "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99"
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n    \"schemas\": [\n        \"urn:ietf:params:scim:api:messages:2.0:Error\"\n    ],\n    \"detail\": \"Your API key was generated by a Team Admin who is no longer on your team. Use an API key generated by a Team Admin.\",\n    \"status\": \"403\"\n}"
    },
    {
      "name": "404 - User Not Found",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "{{apiKey}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{url}}/Users/405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "host": [
            "{{url}}"
          ],
          "path": [
            "Users",
            "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99"
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n    \"schemas\": [\n        \"urn:ietf:params:scim:api:messages:2.0:Error\"\n    ],\n    \"detail\": \"This person isn’t a member of the team.\",\n    \"status\": \"404\"\n}"
    },
    {
      "name": "429 - Rate limit exceeded",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "{{apiKey}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{url}}/Users/405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "host": [
            "{{url}}"
          ],
          "path": [
            "Users",
            "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99"
          ]
        }
      },
      "code": 429,
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n    \"schemas\": [\n        \"urn:ietf:params:scim:api:messages:2.0:Error\"\n    ],\n    \"detail\": \"That’s 300 attempts in less than a minute. Wait for a minute and then try again.\",\n    \"status\": 429\n}"
    },
    {
      "name": "500 - Something went wrong",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "{{apiKey}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{url}}/Users/405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "host": [
            "{{url}}"
          ],
          "path": [
            "Users",
            "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99"
          ]
        }
      },
      "status": "Internal Server Error",
      "code": 500,
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n    \"schemas\": [\n        \"urn:ietf:params:scim:api:messages:2.0:Error\"\n    ],\n    \"detail\": \"Unable to fetch information about this team member.\",\n    \"status\": \"500\"\n}"
    }
  ]
}