ERROR!
------------------- GenerateCode ----------------------
---- begin chilkat script ----
// This example assumes the Chilkat API to have been previously unlocked.
// See {{-global_unlock:::Global Unlock Sample-}} for sample code.
new Http http;
ckbool success;
call http.SetRequestHeader("X-API-Key","{{postman_api_key}}");
new StringBuilder sbResponseBody;
success = http.QuickGetSb("https://api.getpostman.com/collections/{{collection_uid}}",sbResponseBody);
if (success == ckfalse) {
println http.LastErrorText;
return;
}
new JsonObject jResp;
call jResp.LoadSb(sbResponseBody);
jResp.EmitCompact = ckfalse;
println "Response Body:";
println jResp.Emit();
int respStatusCode = http.LastStatus;
println "Response Status Code = ",respStatusCode;
if (respStatusCode >= 400) {
println "Response Header:";
println http.LastHeader;
println "Failed.";
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "collection": {
// "variables": [
// ],
// "info": {
// "name": "Sample Collection",
// "_postman_id": "f2e66c2e-5297-e4a5-739e-20cbb90900e3",
// "description": "This is a sample collection that makes a tiny request to Postman Echo service to get the list of request headers sent by a HTTP client.",
// "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
// },
// "item": [
// {
// "id": "82ee981b-e19f-962a-401e-ea34ebfb4848",
// "name": "Request Headers",
// "event": [
// {
// "listen": "test",
// "script": {
// "type": "text/javascript",
// "exec": "var responseJSON;\ntry {\n tests[\"Body contains headers\"] = responseBody.has(\"headers\");\n responseJSON = JSON.parse(responseBody);\n tests[\"Header contains host\"] = \"host\" in responseJSON.headers;\n tests[\"Header contains test parameter sent as part of request header\"] = \"my-sample-header\" in responseJSON.headers;\n}\ncatch (e) { }\n\n\n\n"
// }
// }
// ],
// "request": {
// "url": "https://echo.getpostman.com/headers",
// "method": "GET",
// "header": [
// {
// "key": "my-sample-header",
// "value": "Lorem ipsum dolor sit amet",
// "description": ""
// }
// ],
// "body": {
// "mode": "formdata",
// "formdata": [
// ]
// },
// "description": ""
// },
// "response": [
// ]
// }
// ]
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: {{.https://tools.chilkat.io/jsonParse|||Generate JSON Parsing Code.}}
#ifdef IS_C_CPP
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
#undef IS_C_CPP
string name;
string v_Url;
string Method;
string Mode;
int j;
int count_j;
string listen;
string v_Type;
string Exec;
string key;
string value;
string description;
Name = jResp.StringOf("collection.info.name");
v_postman_id = jResp.StringOf("collection.info._postman_id");
string Description = jResp.StringOf("collection.info.description");
Schema = jResp.StringOf("collection.info.schema");
i = 0;
count_i = jResp.SizeOfArray("collection.variables");
while i < count_i {
jResp.I = i;
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray("collection.item");
while i < count_i {
jResp.I = i;
id = jResp.StringOf("collection.item[i].id");
name = jResp.StringOf("collection.item[i].name");
v_Url = jResp.StringOf("collection.item[i].request.url");
Method = jResp.StringOf("collection.item[i].request.method");
Mode = jResp.StringOf("collection.item[i].request.body.mode");
Description = jResp.StringOf("collection.item[i].request.description");
j = 0;
count_j = jResp.SizeOfArray("collection.item[i].event");
while j < count_j {
jResp.J = j;
listen = jResp.StringOf("collection.item[i].event[j].listen");
v_Type = jResp.StringOf("collection.item[i].event[j].script.type");
Exec = jResp.StringOf("collection.item[i].event[j].script.exec");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray("collection.item[i].request.header");
while j < count_j {
jResp.J = j;
key = jResp.StringOf("collection.item[i].request.header[j].key");
value = jResp.StringOf("collection.item[i].request.header[j].value");
description = jResp.StringOf("collection.item[i].request.header[j].description");
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray("collection.item[i].request.body.formdata");
while j < count_j {
jResp.J = j;
j = j + 1;
}
j = 0;
count_j = jResp.SizeOfArray("collection.item[i].response");
while j < count_j {
jResp.J = j;
j = j + 1;
}
i = i + 1;
}
---- end chilkat script ----
Xojo / Postman API / Single Collection
Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Dim http As New Chilkat.Http
Dim success As Boolean
http.SetRequestHeader "X-API-Key","{{postman_api_key}}"
Dim sbResponseBody As New Chilkat.StringBuilder
success = http.QuickGetSb("https://api.getpostman.com/collections/{{collection_uid}}",sbResponseBody)
If (success = False) Then
System.DebugLog(http.LastErrorText)
Return
End If
Dim jResp As New Chilkat.JsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = False
System.DebugLog("Response Body:")
System.DebugLog(jResp.Emit())
Dim respStatusCode As Int32
respStatusCode = http.LastStatus
System.DebugLog("Response Status Code = " + Str(respStatusCode))
If (respStatusCode >= 400) Then
System.DebugLog("Response Header:")
System.DebugLog(http.LastHeader)
System.DebugLog("Failed.")
Return
End If
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "collection": {
// "variables": [
// ],
// "info": {
// "name": "Sample Collection",
// "_postman_id": "f2e66c2e-5297-e4a5-739e-20cbb90900e3",
// "description": "This is a sample collection that makes a tiny request to Postman Echo service to get the list of request headers sent by a HTTP client.",
// "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
// },
// "item": [
// {
// "id": "82ee981b-e19f-962a-401e-ea34ebfb4848",
// "name": "Request Headers",
// "event": [
// {
// "listen": "test",
// "script": {
// "type": "text/javascript",
// "exec": "var responseJSON;\ntry {\n tests[\"Body contains headers\"] = responseBody.has(\"headers\");\n responseJSON = JSON.parse(responseBody);\n tests[\"Header contains host\"] = \"host\" in responseJSON.headers;\n tests[\"Header contains test parameter sent as part of request header\"] = \"my-sample-header\" in responseJSON.headers;\n}\ncatch (e) { }\n\n\n\n"
// }
// }
// ],
// "request": {
// "url": "https://echo.getpostman.com/headers",
// "method": "GET",
// "header": [
// {
// "key": "my-sample-header",
// "value": "Lorem ipsum dolor sit amet",
// "description": ""
// }
// ],
// "body": {
// "mode": "formdata",
// "formdata": [
// ]
// },
// "description": ""
// },
// "response": [
// ]
// }
// ]
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Dim name As String
Dim v_Url As String
Dim Method As String
Dim Mode As String
Dim j As Int32
Dim count_j As Int32
Dim listen As String
Dim v_Type As String
Dim Exec As String
Dim key As String
Dim value As String
Dim description As String
ERROR: Undefined variable(Name)
ERROR: Undefined variable(v_postman_id)
Dim Description As String
Description = jResp.StringOf("collection.info.description")
ERROR: Undefined variable(Schema)
ERROR: Undefined variable(i)
ERROR: Undefined variable(count_i)
ERROR: Undefined variable(i)
ERROR: Undefined variable(count_i)
While i < count_i
ERROR: Undefined variable(i)
ERROR: No et type for RHS expression.
ERROR: Undefined variable(i)
ERROR: Missing et type attribute (b)
ERROR: Undefined variable(i)
Wend
ERROR: Undefined variable(i)
ERROR: Undefined variable(count_i)
ERROR: Undefined variable(i)
ERROR: Undefined variable(count_i)
While i < count_i
ERROR: Undefined variable(i)
ERROR: No et type for RHS expression.
ERROR: Undefined variable(id)
name = jResp.StringOf("collection.item[i].name")
v_Url = jResp.StringOf("collection.item[i].request.url")
Method = jResp.StringOf("collection.item[i].request.method")
Mode = jResp.StringOf("collection.item[i].request.body.mode")
Description = jResp.StringOf("collection.item[i].request.description")
j = 0
count_j = jResp.SizeOfArray("collection.item[i].event")
While j < count_j
jResp.J = j
listen = jResp.StringOf("collection.item[i].event[j].listen")
v_Type = jResp.StringOf("collection.item[i].event[j].script.type")
Exec = jResp.StringOf("collection.item[i].event[j].script.exec")
j = j + 1
Wend
j = 0
count_j = jResp.SizeOfArray("collection.item[i].request.header")
While j < count_j
jResp.J = j
key = jResp.StringOf("collection.item[i].request.header[j].key")
value = jResp.StringOf("collection.item[i].request.header[j].value")
description = jResp.StringOf("collection.item[i].request.header[j].description")
j = j + 1
Wend
j = 0
count_j = jResp.SizeOfArray("collection.item[i].request.body.formdata")
While j < count_j
jResp.J = j
j = j + 1
Wend
j = 0
count_j = jResp.SizeOfArray("collection.item[i].response")
While j < count_j
jResp.J = j
j = j + 1
Wend
ERROR: Undefined variable(i)
ERROR: Missing et type attribute (b)
ERROR: Undefined variable(i)
Wend
Curl Command
curl -X GET
-H "X-API-Key: {{postman_api_key}}"
https://api.getpostman.com/collections/{{collection_uid}}
Postman Collection Item JSON
{
"name": "Single Collection ",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test(\"response is ok\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"response json data should not have errors\", function () {",
" pm.response.to.have.jsonBody();",
" pm.response.to.not.have.jsonBody('error');",
"});",
"",
"pm.test(\"response json should contain one collection\", function () {",
" pm.expect(pm.response.json()).to.have.property('collection').and.be.an('object');",
"});",
"",
"// additional tests to ensure that the relevant environment variables are present",
"pm.test('\"postman_api_key\" variable should be present', function () {",
" pm.expect(pm.variables.get('postman_api_key')).to.be.a('string');",
"});",
"",
"// you can unskip this test in case you want to have a stricter check on the selected",
"// environment.",
"pm.test.skip('\"collection_uid\" variable should be present', function () {",
" pm.expect(pm.variables.get('collection_uid')).to.be.a('string');",
"});"
]
}
}
],
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/collections/{{collection_uid}}",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections",
"{{collection_uid}}"
]
},
"description": "Access the contents of a collection that is accessible to you using its unique id (`uid`).\n\n> Requires <a href=\"#authentication\">API Key</a> as `X-Api-Key` request header or `apikey` URL query parameter."
},
"response": [
{
"name": "Valid Response",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/collections/{{collection_uid}}",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections",
"{{collection_uid}}"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"name": "Content-Type",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [
],
"body": "{\n \"collection\": {\n \"variables\": [],\n \"info\": {\n \"name\": \"Sample Collection\",\n \"_postman_id\": \"f2e66c2e-5297-e4a5-739e-20cbb90900e3\",\n \"description\": \"This is a sample collection that makes a tiny request to Postman Echo service to get the list of request headers sent by a HTTP client.\",\n \"schema\": \"https://schema.getpostman.com/json/collection/v2.0.0/collection.json\"\n },\n \"item\": [\n {\n \"id\": \"82ee981b-e19f-962a-401e-ea34ebfb4848\",\n \"name\": \"Request Headers\",\n \"event\": [\n {\n \"listen\": \"test\",\n \"script\": {\n \"type\": \"text/javascript\",\n \"exec\": \"var responseJSON;\\ntry {\\n tests[\\\"Body contains headers\\\"] = responseBody.has(\\\"headers\\\");\\n responseJSON = JSON.parse(responseBody);\\n tests[\\\"Header contains host\\\"] = \\\"host\\\" in responseJSON.headers;\\n tests[\\\"Header contains test parameter sent as part of request header\\\"] = \\\"my-sample-header\\\" in responseJSON.headers;\\n}\\ncatch (e) { }\\n\\n\\n\\n\"\n }\n }\n ],\n \"request\": {\n \"url\": \"https://echo.getpostman.com/headers\",\n \"method\": \"GET\",\n \"header\": [\n {\n \"key\": \"my-sample-header\",\n \"value\": \"Lorem ipsum dolor sit amet\",\n \"description\": \"\"\n }\n ],\n \"body\": {\n \"mode\": \"formdata\",\n \"formdata\": []\n },\n \"description\": \"\"\n },\n \"response\": []\n }\n ]\n }\n}"
}
]
}