-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay 04- Authorization.postman_collection.json
692 lines (692 loc) · 28 KB
/
Day 04- Authorization.postman_collection.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
{
"info": {
"_postman_id": "46329901-9e46-4246-b6f3-e8fa1f12074e",
"name": "Day 04: Authorization",
"description": "## Instructions for Day 4: Authorization\n\n1. **Get the challenge:** Fork the parent collection to your own public workspace.\n2. **Read the documentation:** Select the first folder. Expand the context bar on the right to follow the instructions in the collection documentation.\n3. **Submit your solution:** Select the second folder and follow the instructions in the documentation to validate your solution.\n\n## Learning objectives\n- Authorize API requests by using API key\n- Use an authorization helper\n- Explain inheritance regarding auth type\n- Authorize API requests by using cookies\n\n## Concepts covered\n\n* [Authorize requests](https://learning.postman.com/docs/sending-requests/authorization/)\n* [Inheriting Auth Details](https://youtu.be/WFiYsfSkyXE) video\n* [Securely using API keys in Postman](https://blog.postman.com/how-to-use-api-keys/) blog\n\n## Additional resources\n\n* [Use cookies](https://learning.postman.com/docs/sending-requests/cookies/) docs\n* [Sync cookies for authentication](https://youtu.be/jfgFNw5SoUg) video",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "3488052"
},
"item": [
{
"name": "Authorization",
"item": [
{
"name": "All Collections - header",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections"
],
"query": [
{
"key": "workspace",
"value": "{{workspaceId}}",
"description": "Optional. A workspace ID.",
"disabled": true
}
]
},
"description": "Gets all of your [collections](https://www.getpostman.com/docs/collections). The response includes all of your subscribed collections."
},
"response": [
{
"name": "Successful Response",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections"
],
"query": [
{
"key": "workspace",
"value": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
"description": "Optional. A workspace ID.",
"disabled": true
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [],
"body": "{\n \"collections\": [\n {\n \"id\": \"dac5eac9-148d-a32e-b76b-3edee9da28f7\",\n \"name\": \"Cloud API\",\n \"owner\": \"12345678\",\n \"createdAt\": \"2022-04-12T10:29:46.000Z\",\n \"updatedAt\": \"2022-04-12T10:29:56.000Z\",\n \"uid\": \"12345678-dac5eac9-148d-a32e-b76b-3edee9da28f7\",\n \"isPublic\": true\n },\n {\n \"id\": \"12ece9e1-2abf-4edc-8e34-de66e74114d2\",\n \"name\": \"Test Collection\",\n \"owner\": \"12345678\",\n \"createdAt\": \"2022-01-13T10:21:46.000Z\",\n \"updatedAt\": \"2022-02-12T11:29:56.000Z\",\n \"uid\": \"12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2\",\n \"isPublic\": false,\n \"fork\": {\n \"label\": \"Test Fork\",\n \"createdAt\": \"2022-06-16T19:51:44.069Z\",\n \"from\": \"12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2\"\n }\n },\n {\n \"id\": \"f695cab7-6878-eb55-7943-ad88e1ccfd65\",\n \"name\": \"Postman Echo\",\n \"owner\": \"12345678\",\n \"createdAt\": \"2021-04-11T09:18:26.000Z\",\n \"updatedAt\": \"2022-05-01T15:29:32.000Z\",\n \"uid\": \"12345678-f695cab7-6878-eb55-7943-ad88e1ccfd65\",\n \"isPublic\": true\n }\n ]\n}"
},
{
"name": "Filter by Workspace",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections"
],
"query": [
{
"key": "workspace",
"value": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
"description": "Optional. A workspace ID."
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [],
"body": "{\n \"collections\": [\n {\n \"id\": \"dac5eac9-148d-a32e-b76b-3edee9da28f7\",\n \"name\": \"Cloud API\",\n \"owner\": \"12345678\",\n \"createdAt\": \"2022-04-12T10:29:46.000Z\",\n \"updatedAt\": \"2022-04-12T10:29:56.000Z\",\n \"uid\": \"12345678-dac5eac9-148d-a32e-b76b-3edee9da28f7\",\n \"isPublic\": true\n }\n ]\n}"
},
{
"name": "Rate Limit Exceeded",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections"
],
"query": [
{
"key": "workspace",
"value": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
"description": "Optional. A workspace ID.",
"disabled": true
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [],
"body": "{\n \"error\": \"rateLimited\",\n \"message\": \"Rate limit exceeded. Please retry after 1669048687\"\n}"
}
]
},
{
"name": "All Collections - query params",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections"
],
"query": [
{
"key": "workspace",
"value": "{{workspaceId}}",
"description": "Optional. A workspace ID.",
"disabled": true
}
]
},
"description": "Gets all of your [collections](https://www.getpostman.com/docs/collections). The response includes all of your subscribed collections."
},
"response": [
{
"name": "Successful Response",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections"
],
"query": [
{
"key": "workspace",
"value": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
"description": "Optional. A workspace ID.",
"disabled": true
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [],
"body": "{\n \"collections\": [\n {\n \"id\": \"dac5eac9-148d-a32e-b76b-3edee9da28f7\",\n \"name\": \"Cloud API\",\n \"owner\": \"12345678\",\n \"createdAt\": \"2022-04-12T10:29:46.000Z\",\n \"updatedAt\": \"2022-04-12T10:29:56.000Z\",\n \"uid\": \"12345678-dac5eac9-148d-a32e-b76b-3edee9da28f7\",\n \"isPublic\": true\n },\n {\n \"id\": \"12ece9e1-2abf-4edc-8e34-de66e74114d2\",\n \"name\": \"Test Collection\",\n \"owner\": \"12345678\",\n \"createdAt\": \"2022-01-13T10:21:46.000Z\",\n \"updatedAt\": \"2022-02-12T11:29:56.000Z\",\n \"uid\": \"12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2\",\n \"isPublic\": false,\n \"fork\": {\n \"label\": \"Test Fork\",\n \"createdAt\": \"2022-06-16T19:51:44.069Z\",\n \"from\": \"12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2\"\n }\n },\n {\n \"id\": \"f695cab7-6878-eb55-7943-ad88e1ccfd65\",\n \"name\": \"Postman Echo\",\n \"owner\": \"12345678\",\n \"createdAt\": \"2021-04-11T09:18:26.000Z\",\n \"updatedAt\": \"2022-05-01T15:29:32.000Z\",\n \"uid\": \"12345678-f695cab7-6878-eb55-7943-ad88e1ccfd65\",\n \"isPublic\": true\n }\n ]\n}"
},
{
"name": "Filter by Workspace",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections"
],
"query": [
{
"key": "workspace",
"value": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
"description": "Optional. A workspace ID."
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [],
"body": "{\n \"collections\": [\n {\n \"id\": \"dac5eac9-148d-a32e-b76b-3edee9da28f7\",\n \"name\": \"Cloud API\",\n \"owner\": \"12345678\",\n \"createdAt\": \"2022-04-12T10:29:46.000Z\",\n \"updatedAt\": \"2022-04-12T10:29:56.000Z\",\n \"uid\": \"12345678-dac5eac9-148d-a32e-b76b-3edee9da28f7\",\n \"isPublic\": true\n }\n ]\n}"
},
{
"name": "Rate Limit Exceeded",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections"
],
"query": [
{
"key": "workspace",
"value": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
"description": "Optional. A workspace ID.",
"disabled": true
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [],
"body": "{\n \"error\": \"rateLimited\",\n \"message\": \"Rate limit exceeded. Please retry after 1669048687\"\n}"
}
]
},
{
"name": "All Collections - auth helper",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections"
],
"query": [
{
"key": "workspace",
"value": "{{workspaceId}}",
"description": "Optional. A workspace ID.",
"disabled": true
}
]
},
"description": "Gets all of your [collections](https://www.getpostman.com/docs/collections). The response includes all of your subscribed collections."
},
"response": [
{
"name": "Successful Response",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections"
],
"query": [
{
"key": "workspace",
"value": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
"description": "Optional. A workspace ID.",
"disabled": true
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [],
"body": "{\n \"collections\": [\n {\n \"id\": \"dac5eac9-148d-a32e-b76b-3edee9da28f7\",\n \"name\": \"Cloud API\",\n \"owner\": \"12345678\",\n \"createdAt\": \"2022-04-12T10:29:46.000Z\",\n \"updatedAt\": \"2022-04-12T10:29:56.000Z\",\n \"uid\": \"12345678-dac5eac9-148d-a32e-b76b-3edee9da28f7\",\n \"isPublic\": true\n },\n {\n \"id\": \"12ece9e1-2abf-4edc-8e34-de66e74114d2\",\n \"name\": \"Test Collection\",\n \"owner\": \"12345678\",\n \"createdAt\": \"2022-01-13T10:21:46.000Z\",\n \"updatedAt\": \"2022-02-12T11:29:56.000Z\",\n \"uid\": \"12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2\",\n \"isPublic\": false,\n \"fork\": {\n \"label\": \"Test Fork\",\n \"createdAt\": \"2022-06-16T19:51:44.069Z\",\n \"from\": \"12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2\"\n }\n },\n {\n \"id\": \"f695cab7-6878-eb55-7943-ad88e1ccfd65\",\n \"name\": \"Postman Echo\",\n \"owner\": \"12345678\",\n \"createdAt\": \"2021-04-11T09:18:26.000Z\",\n \"updatedAt\": \"2022-05-01T15:29:32.000Z\",\n \"uid\": \"12345678-f695cab7-6878-eb55-7943-ad88e1ccfd65\",\n \"isPublic\": true\n }\n ]\n}"
},
{
"name": "Filter by Workspace",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections"
],
"query": [
{
"key": "workspace",
"value": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
"description": "Optional. A workspace ID."
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [],
"body": "{\n \"collections\": [\n {\n \"id\": \"dac5eac9-148d-a32e-b76b-3edee9da28f7\",\n \"name\": \"Cloud API\",\n \"owner\": \"12345678\",\n \"createdAt\": \"2022-04-12T10:29:46.000Z\",\n \"updatedAt\": \"2022-04-12T10:29:56.000Z\",\n \"uid\": \"12345678-dac5eac9-148d-a32e-b76b-3edee9da28f7\",\n \"isPublic\": true\n }\n ]\n}"
},
{
"name": "Rate Limit Exceeded",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections"
],
"query": [
{
"key": "workspace",
"value": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
"description": "Optional. A workspace ID.",
"disabled": true
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [],
"body": "{\n \"error\": \"rateLimited\",\n \"message\": \"Rate limit exceeded. Please retry after 1669048687\"\n}"
}
]
}
],
"description": "It's time to work on your next challenge.\n\nThe [Postman API](https://learning.postman.com/docs/developer/intro-api/) lets you programmatically access data stored in your Postman account. This API requires an API key to tell the API server that a request it receives is from you and that you are allowed access to the data. Take a look at the documentation and browse the collection.\n\n1. **Add a request**: Fork the [Postman API collection](https://www.postman.com/postman/workspace/postman-public-workspace/collection/12959542-c8142d51-e97c-46b6-bd77-52bb66712c9a?ctx=documentation) to your public workspace in the same way you forked today's challenge. Then find a request to get all of your collections. Duplicate it, and drag the copy over to this folder `Authorization`. Rename the request `All Collections - header`.\n1. **Add a header**: In the collection documentation, we see there are two ways to authorize this particular request. Let's start with adding an authorization header. Under the **Headers** tab, add a key `x-api-key` with the value <code>\\{{postman_api_key\\}}</code>. Hover over the variable to make sure Postman is reading in the correct value from an active environment. If the Postman API key is not already added to your environment, do that now. **Send** to make sure you receive a 200 status code, and then **Save** your changes.\n1. **Add a query parameter**: Duplicate the request, and rename the request `All Collections - query params`. In this new request, delete the header you added in the previous request. Again, following the instructions in the collection documentation for this particular API, go to the **Params** tab. Add a key `apikey` with a value <code>\\{{postman_api_key\\}}</code>. **Send** to make sure you receive a 200 status code, and then **Save** your changes.\n1. **Add an auth helper**: Instead of manually adding a header or params, let's use one of the authorization helpers provided by Postman. Duplicate the last request, and rename the request `All Collections - auth helper`. Delete the key-value pair under the **Params** tab. Under the **Authorization** tab, select `API key` type from the dropdown. Add `x-api-key` and <code>\\{{postman_api_key\\}}</code> to be added as a header. **Send** to make sure you receive a 200 status code, and then save your changes. Look under **Headers** to see the header that Postman auto-generated from the auth helper.\n1. **Add collection-level auth**: Since all of the requests in this collection require the same authorization method, let's add a collection-level authorization helper. For each of these three requests, delete the added header, delete the params, and update the Auth type to `Inherit auth from parent`. The parent of this request is the folder or collection that contains these requests. Select the collection `Authorization`, and add the `API key` auth helper under the `Authorization` tab like you did in the previous step. **Send** at least one of the requests to make sure you receive a 200 status code, and then save all of your changes.\n\nThere's a number of ways API servers can require authorization. Take a look at the other [auth helpers](https://learning.postman.com/docs/sending-requests/authorization/) available in Postman.\n\nPostman can capture cookies for a browser or client application using the [Postman proxy](https://learning.postman.com/docs/sending-requests/capturing-request-data/capturing-http-requests/) or [Postman Interceptor](https://learning.postman.com/docs/sending-requests/capturing-request-data/interceptor/). You can't sync cookies with the Postman web app. Make sure you've installed the Postman desktop app. Take a look at the additional resources and try syncing cookies on your own.\n\nOnce you complete these steps, move on to the next folder in this collection to submit your solution. Follow the instructions in the request documentation.",
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
]
},
{
"name": "Submit your solution",
"item": [
{
"name": "submit collection",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// counter for passed tests",
"let pass = 0",
"let totalToPass = 5",
"",
"let collection = pm.response.json().collection",
"",
"pm.test(\"If you have any failures, review the failed test results or ask for support in the community forum. Remember to save your changes if you update the collection. When all of your tests pass, you are done with today's challenge.\", () => {",
" pm.expect(true);",
" pass += 1",
"});",
"",
"pm.test(\"Status code is 200\", () => {",
" pm.response.to.have.status(200);",
" pass += 1",
"});",
"",
"pm.test(\"Correct collection returned\", () => {",
" pm.expect(collection.info.name).equals(\"Day 04: Authorization\")",
" pass += 1",
"})",
"",
"let folder = collection.item.find(fol => {return fol.name === \"Authorization\"})",
"",
"pm.test(\"Requests added correctly\", () => {",
" pm.expect(collection.item[0].item.length, 'check number of requests').equals(3)",
"",
" let headerRequest = collection.item[0].item.find(req => { return req.name === \"All Collections - header\"})",
" let queryRequest = collection.item[0].item.find(req => { return req.name === \"All Collections - query params\"})",
" let authRequest = collection.item[0].item.find(req => { return req.name === \"All Collections - auth helper\"})",
" pm.expect(headerRequest.name, 'check name').equals(\"All Collections - header\")",
" pm.expect(queryRequest.name, 'check name').equals(\"All Collections - query params\")",
" pm.expect(authRequest.name, 'check name').equals(\"All Collections - auth helper\")",
"",
" pass += 1",
"})",
"",
"pm.test(\"Auth added correctly\", () => {",
" pm.expect(collection.auth.type, 'check auth type').equals(\"apikey\")",
" pm.expect(collection.auth.apikey[0].value, 'check api key').contains.oneOf([\"X-api-key\", \"{{postman_api_key}}\"])",
"",
" pass += 1",
"})",
"",
"// visualization for test results",
"let template",
"if (pass == totalToPass) {",
" template = `🍪 passing!",
" <br />",
" <img src=\"https://media2.giphy.com/media/dudcZA9e14HIY/giphy.gif?cid=ecf05e47uvc5i15fc8a33uuwpv5ymtmgqj2g8p2lp5nc6xke&rid=giphy.gif&ct=g\" />",
" `",
"} else {",
" template = `🙅 please try again",
" <br />",
" <img src=\"https://media3.giphy.com/media/ZQvBOPZCn0LfO/giphy.gif?cid=ecf05e473v2u4e51l0p7rd6pvxim8kqrbu6yqioz36uyngp4&rid=giphy.gif&ct=g\" />",
" `",
"}",
"pm.visualizer.set(template)"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.getpostman.com/collections/{{collection_uid}}",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"collections",
"{{collection_uid}}"
]
},
"description": "It's time to check your collection.\n\n1. **Get the collection ID:** Select the collection in the sidebar. Then in the context bar to the right, select the `Info` icon and copy the collection `ID`.\n2. **Update the request URL:** Update the `collection_uid` in the request URL with the collection `ID` from the previous step, using any method you prefer.\n3. **Get your Postman API key**: Get your [Postman API key](https://go.postman.co/settings/me/api-keys), and add your API key using any method you prefer. For example, you can create an environment variable and reuse your credentials throughout the remainder of these challenges. Make sure to paste the value under `CURRENT VALUE` (and not `INITIAL VALUE`) and save your changes.\n \n > ⚠ DON'T LEAK YOUR SECRETS! \n > It's very important to add sensitive values like an API key to the `CURRENT VALUE` (and not `INITIAL VALUE`) of your public workspace.\n \n4. **Validate your solution**: Hit **Send** and look under the **Tests** tab of the server response at the bottom to review your test results.\n \nIf you have any failures, [review the failed test results](https://youtu.be/S3GKLTVRtmE) or ask for support in the [community forum](https://community.postman.com/). When all of your tests pass, you are done with today's challenge."
},
"response": []
}
],
"description": "Follow the instructions in the request documentation.",
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
]
}
],
"auth": {
"type": "apikey",
"apikey": [
{
"key": "value",
"value": "{{postman_api_key}}",
"type": "string"
},
{
"key": "key",
"value": "x-api-key",
"type": "string"
}
]
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "collection_uid",
"value": "",
"type": "string"
}
]
}