DataFlex / Postman API / Get linked relations
Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sId
String sName
String sUpdatedAt
String sV_521b0486_ab91_4d3a_9189_43c9380a0533Id
String sV_521b0486_ab91_4d3a_9189_43c9380a0533Name
String sV_521b0486_ab91_4d3a_9189_43c9380a0533UpdatedAt
String sA236b715_e682_460b_97b6_c1db24f7612eId
String sA236b715_e682_460b_97b6_c1db24f7612eName
String sA236b715_e682_460b_97b6_c1db24f7612eUpdatedAt
String sV_4ccd755f_2c80_481b_a262_49b55e12f5e1Id
String sV_4ccd755f_2c80_481b_a262_49b55e12f5e1Name
String sV_Url
String sV_4ccd755f_2c80_481b_a262_49b55e12f5e1UpdatedAt
String sTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Send ComSetRequestHeader To hoHttp "X-API-Key" "{{postman_api_key}}"
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComQuickGetSb Of hoHttp "https://api.getpostman.com/apis/{{apiId}}/versions/{{apiVersionId}}/relations" vSbResponseBody To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComLastStatus Of hoHttp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComLastHeader Of hoHttp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_Return
End
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "relations": {
// "contracttest": {
// "2a9b8fa8-88b7-4b86-8372-8e3f6f6e07f2": {
// "id": "2a9b8fa8-88b7-4b86-8372-8e3f6f6e07f2",
// "name": "C test",
// "updatedAt": "2019-08-29T10:18:11.000Z"
// }
// },
// "integrationtest": {
// "521b0486-ab91-4d3a-9189-43c9380a0533": {
// "id": "521b0486-ab91-4d3a-9189-43c9380a0533",
// "name": "C1",
// "updatedAt": "2019-08-29T11:40:39.000Z"
// },
// "a236b715-e682-460b-97b6-c1db24f7612e": {
// "id": "a236b715-e682-460b-97b6-c1db24f7612e",
// "name": "C test",
// "updatedAt": "2019-08-29T10:18:11.000Z"
// }
// },
// "mock": {
// "4ccd755f-2c80-481b-a262-49b55e12f5e1": {
// "id": "4ccd755f-2c80-481b-a262-49b55e12f5e1",
// "name": "Mock",
// "url": "https://4ccd755f-2c80-481b-a262-49b55e12f5e1.mock-beta.pstmn.io",
// "updatedAt": "2019-08-20T10:18:13.000Z"
// }
// }
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Get ComStringOf Of hoJResp "relations.contracttest.2a9b8fa8-88b7-4b86-8372-8e3f6f6e07f2.id" To sId
Get ComStringOf Of hoJResp "relations.contracttest.2a9b8fa8-88b7-4b86-8372-8e3f6f6e07f2.name" To sName
Get ComStringOf Of hoJResp "relations.contracttest.2a9b8fa8-88b7-4b86-8372-8e3f6f6e07f2.updatedAt" To sUpdatedAt
Get ComStringOf Of hoJResp "relations.integrationtest.521b0486-ab91-4d3a-9189-43c9380a0533.id" To sV_521b0486_ab91_4d3a_9189_43c9380a0533Id
Get ComStringOf Of hoJResp "relations.integrationtest.521b0486-ab91-4d3a-9189-43c9380a0533.name" To sV_521b0486_ab91_4d3a_9189_43c9380a0533Name
Get ComStringOf Of hoJResp "relations.integrationtest.521b0486-ab91-4d3a-9189-43c9380a0533.updatedAt" To sV_521b0486_ab91_4d3a_9189_43c9380a0533UpdatedAt
Get ComStringOf Of hoJResp "relations.integrationtest.a236b715-e682-460b-97b6-c1db24f7612e.id" To sA236b715_e682_460b_97b6_c1db24f7612eId
Get ComStringOf Of hoJResp "relations.integrationtest.a236b715-e682-460b-97b6-c1db24f7612e.name" To sA236b715_e682_460b_97b6_c1db24f7612eName
Get ComStringOf Of hoJResp "relations.integrationtest.a236b715-e682-460b-97b6-c1db24f7612e.updatedAt" To sA236b715_e682_460b_97b6_c1db24f7612eUpdatedAt
Get ComStringOf Of hoJResp "relations.mock.4ccd755f-2c80-481b-a262-49b55e12f5e1.id" To sV_4ccd755f_2c80_481b_a262_49b55e12f5e1Id
Get ComStringOf Of hoJResp "relations.mock.4ccd755f-2c80-481b-a262-49b55e12f5e1.name" To sV_4ccd755f_2c80_481b_a262_49b55e12f5e1Name
Get ComStringOf Of hoJResp "relations.mock.4ccd755f-2c80-481b-a262-49b55e12f5e1.url" To sV_Url
Get ComStringOf Of hoJResp "relations.mock.4ccd755f-2c80-481b-a262-49b55e12f5e1.updatedAt" To sV_4ccd755f_2c80_481b_a262_49b55e12f5e1UpdatedAt
End_Procedure
Curl Command
curl -X GET
-H "X-API-Key: {{postman_api_key}}"
https://api.getpostman.com/apis/{{apiId}}/versions/{{apiVersionId}}/relations
Postman Collection Item JSON
{
"name": "Get linked relations",
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/apis/{{apiId}}/versions/{{apiVersionId}}/relations",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"apis",
"{{apiId}}",
"versions",
"{{apiVersionId}}",
"relations"
]
},
"description": "This call fetches all the relations which are linked to the specified API version along with their details.\n\nThe response will contain a `relations` object which lists all the relation types which are linked to the API version. Each of the relation type will be an object which details the relations of this type. \n\n> Requires <a href=\"#authentication\">API Key</a> as `X-Api-Key` request header or `apikey` URL query parameter."
},
"response": [
{
"name": "Get linked relations for an API version",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/apis/{{apiId}}/versions/{{apiVersionId}}/relations",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"apis",
"{{apiId}}",
"versions",
"{{apiVersionId}}",
"relations"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [
],
"body": "{\n\t\"relations\": {\n\t\t\"contracttest\": {\n \"2a9b8fa8-88b7-4b86-8372-8e3f6f6e07f2\": {\n \"id\": \"2a9b8fa8-88b7-4b86-8372-8e3f6f6e07f2\",\n \"name\": \"C test\",\n \"updatedAt\": \"2019-08-29T10:18:11.000Z\"\n }\n },\n \"integrationtest\": {\n \"521b0486-ab91-4d3a-9189-43c9380a0533\": {\n \"id\": \"521b0486-ab91-4d3a-9189-43c9380a0533\",\n \"name\": \"C1\",\n \"updatedAt\": \"2019-08-29T11:40:39.000Z\"\n },\n \"a236b715-e682-460b-97b6-c1db24f7612e\": {\n \"id\": \"a236b715-e682-460b-97b6-c1db24f7612e\",\n \"name\": \"C test\",\n \"updatedAt\": \"2019-08-29T10:18:11.000Z\"\n }\n },\n \"mock\": {\n \"4ccd755f-2c80-481b-a262-49b55e12f5e1\": {\n \"id\": \"4ccd755f-2c80-481b-a262-49b55e12f5e1\",\n \"name\": \"Mock\",\n \"url\": \"https://4ccd755f-2c80-481b-a262-49b55e12f5e1.mock-beta.pstmn.io\",\n \"updatedAt\": \"2019-08-20T10:18:13.000Z\"\n }\n }\n\t}\n}"
}
]
}