Chilkat Online Tools

SQL Server / Postman API / Sync relations with schema

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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-API-Key', '{{postman_api_key}}'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'QuickRequest', @resp OUT, 'PUT', 'https://api.getpostman.com/apis/:apiId/versions/:apiVersionId/:entityType/:entityId/syncWithSchema'
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @http


END
GO

Curl Command

curl -X PUT
	-H "X-API-Key: {{postman_api_key}}"
https://api.getpostman.com/apis/:apiId/versions/:apiVersionId/:entityType/:entityId/syncWithSchema

Postman Collection Item JSON

{
  "name": "Sync relations with schema",
  "request": {
    "method": "PUT",
    "header": [
    ],
    "url": {
      "raw": "https://api.getpostman.com/apis/:apiId/versions/:apiVersionId/:entityType/:entityId/syncWithSchema",
      "protocol": "https",
      "host": [
        "api",
        "getpostman",
        "com"
      ],
      "path": [
        "apis",
        ":apiId",
        "versions",
        ":apiVersionId",
        ":entityType",
        ":entityId",
        "syncWithSchema"
      ],
      "variable": [
        {
          "key": "apiId",
          "value": "{{apiId}}",
          "description": "Id of the API"
        },
        {
          "key": "apiVersionId",
          "value": "{{apiVersionId}}",
          "description": "Id of the API version"
        },
        {
          "key": "entityType",
          "value": "{{entityType}}",
          "description": "Relation type (e.g documentation, contracttest, integrationtest, testsuite, mock, monitor)"
        },
        {
          "key": "entityId",
          "value": "{{entityId}}",
          "description": "Relation id"
        }
      ]
    },
    "description": "This call allows you to keep the relation in sync with the API schema.\n\n\n> Requires <a href=\"#authentication\">API Key</a> as `X-Api-Key` request header or `apikey` URL query parameter."
  },
  "response": [
    {
      "name": "Failed to sync",
      "originalRequest": {
        "method": "PUT",
        "header": [
        ],
        "url": {
          "raw": "https://api.getpostman.com/apis/:apiId/versions/:apiVersionId/:entityType/:entityId/syncWithSchema",
          "protocol": "https",
          "host": [
            "api",
            "getpostman",
            "com"
          ],
          "path": [
            "apis",
            ":apiId",
            "versions",
            ":apiVersionId",
            ":entityType",
            ":entityId",
            "syncWithSchema"
          ],
          "variable": [
            {
              "key": "apiId",
              "value": ""
            },
            {
              "key": "apiVersionId",
              "value": ""
            },
            {
              "key": "entityType",
              "value": ""
            },
            {
              "key": "entityId",
              "value": ""
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n    \"error\": {\n        \"name\": \"validationFailed\",\n        \"message\": \"Unable to validate. Only the OpenAPI 3.0 schema format is supported.\"\n    }\n}"
    },
    {
      "name": "Successful sync",
      "originalRequest": {
        "method": "PUT",
        "header": [
        ],
        "url": {
          "raw": "https://api.getpostman.com/apis/:apiId/versions/:apiVersionId/:entityType/:entityId/syncWithSchema",
          "protocol": "https",
          "host": [
            "api",
            "getpostman",
            "com"
          ],
          "path": [
            "apis",
            ":apiId",
            "versions",
            ":apiVersionId",
            ":entityType",
            ":entityId",
            "syncWithSchema"
          ],
          "variable": [
            {
              "key": "apiId",
              "value": "{{apiId}}",
              "description": "Id of the API"
            },
            {
              "key": "apiVersionId",
              "value": "{{apiVersionId}}",
              "description": "Id of the API version"
            },
            {
              "key": "entityType",
              "value": "{{entityType}}",
              "description": "Relation type (e.g documentation, contracttest, integrationtest, testsuite, mock, monitor)"
            },
            {
              "key": "entityId",
              "value": "{{entityId}}",
              "description": "Relation id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n    \"success\": true\n}"
    }
  ]
}