This repository has been archived by the owner on Feb 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathEthos Integration Examples.postman_collection.json
827 lines (827 loc) · 26.1 KB
/
Ethos Integration Examples.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
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
{
"info": {
"_postman_id": "ca5c946e-a69c-467f-9de0-f5c1a218ea2c",
"name": "Ethos Integration Examples",
"description": "This collection includes examples of how to make some of the most common API calls through Ethos Integration.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "24134694"
},
"item": [
{
"name": "Ethos Administration Endpoints",
"item": [
{
"name": "/admin/available-resources",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://integrate.elluciancloud.com/admin/available-resources",
"protocol": "https",
"host": [
"integrate",
"elluciancloud",
"com"
],
"path": [
"admin",
"available-resources"
]
}
},
"response": []
},
{
"name": "/appconfig",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://integrate.elluciancloud.com/appconfig",
"protocol": "https",
"host": [
"integrate",
"elluciancloud",
"com"
],
"path": [
"appconfig"
]
},
"description": "[Ellucian Doc](https://resources.elluciancloud.com/bundle/ethos_integration_ref_apis/page/r_application_configuration.html)"
},
"response": []
},
{
"name": "/errors",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://integrate.elluciancloud.com/errors",
"protocol": "https",
"host": [
"integrate",
"elluciancloud",
"com"
],
"path": [
"errors"
]
},
"description": "[Ellucian Doc](https://resources.elluciancloud.com/bundle/ethos_integration_ref_apis/page/r_errors_api.html)"
},
"response": []
},
{
"name": "/audit-logs",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://integrate.elluciancloud.com/audit-logs",
"protocol": "https",
"host": [
"integrate",
"elluciancloud",
"com"
],
"path": [
"audit-logs"
]
}
},
"response": []
},
{
"name": "/consume",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://integrate.elluciancloud.com/consume",
"protocol": "https",
"host": [
"integrate",
"elluciancloud",
"com"
],
"path": [
"consume"
]
}
},
"response": []
},
{
"name": "/admin/resources/{resource}/health",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://integrate.elluciancloud.com/admin/resources/buildings/health",
"protocol": "https",
"host": [
"integrate",
"elluciancloud",
"com"
],
"path": [
"admin",
"resources",
"buildings",
"health"
]
}
},
"response": []
},
{
"name": "/appMetrics",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://integrate.elluciancloud.com/appMetrics",
"protocol": "https",
"host": [
"integrate",
"elluciancloud",
"com"
],
"path": [
"appMetrics"
]
}
},
"response": []
}
]
},
{
"name": "Some Basics",
"item": [
{
"name": "Use API Key to get Access Token",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var newToken = responseBody;",
"postman.setEnvironmentVariable(\"Access Token\", newToken);"
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "00000000-0000-0000-0000-000000000000",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{API Key}}"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "https://integrate.elluciancloud.com/auth",
"protocol": "https",
"host": [
"integrate",
"elluciancloud",
"com"
],
"path": [
"auth"
]
},
"description": "All applications must make this request.\n\nApplications must call the /auth endpoint with their API Key and be issued an Access Token by Ethos Integration. The Access Token (in jwt format) is then used to invoke all other Ethos Integration APIs.\n\nIn this postman collection the /auth call is done automatically by the pre-request script."
},
"response": []
},
{
"name": "Read all courses resource",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "courses",
"host": [
"courses"
]
},
"description": "This API request is a GET to return a collection of courses resources. \n\nThe authoritative system may return a collection that contains all of the courses available or, if the dataset is large, a page. Included in the response headers will be information indicating how many total courses exist in the authoritative system and how many were returned in this response."
},
"response": []
},
{
"name": "Read all email-types resource",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "email-types",
"host": [
"email-types"
]
},
"description": "This API request is a GET to return a collection of email-types resources. \n\nThe authoritative system may return a collection that contains all of the email-types available or, if the dataset is large, a page. Included in the response headers will be information indicating how many total email-types exist in the authoritative system and how many were returned in this response."
},
"response": []
},
{
"name": "Read all persons resource",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "persons",
"host": [
"persons"
]
},
"description": "This API request is a GET to return a collection of persons resources. \n\nThe authoritative system may return a collection that contains all of the courses available or, if the dataset is large, a page. Included in the response headers will be information indicating how many total persons exist in the authoritative system and how many were returned in this response."
},
"response": []
},
{
"name": "Update a persons resource",
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/vnd.hedtech.integration.v8+json"
},
{
"key": "Accept",
"value": "application/vnd.hedtech.integration.v8+json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"privacyStatus\": {\n \"privacyCategory\": \"unrestricted\"\n },\n \"names\": [\n {\n \"type\": {\n \"category\": \"legal\",\n \"detail\": {\n \"id\": \"5e59d3e4-61a8-4f61-9a18-05ae62a5b003\"\n }\n },\n \"fullName\": \"Mr. James Smith\",\n \"title\": \"Mr.\",\n \"firstName\": \"James\",\n \"lastName\": \"Smith\",\n \"preference\": \"preferred\"\n }\n ],\n \"dateOfBirth\": \"1994-12-07\",\n \"gender\": \"male\",\n \"roles\": [\n {\n \"role\": \"student\"\n }\n ],\n \"credentials\": [\n {\n \"type\": \"colleaguePersonId\",\n \"value\": \"0000255\"\n },\n {\n \"type\": \"ssn\",\n \"value\": \"135-79-2468\"\n }\n ],\n \"addresses\": [\n {\n \"address\": {\n \"id\": \"1cd57963-6f6b-4df0-b8eb-dec4a0a72e58\"\n },\n \"type\": {\n \"addressType\": \"home\",\n \"detail\": {\n \"id\": \"c70b16d2-be85-4d43-a4b6-c13941c50d6e\"\n }\n },\n \"startOn\": \"2001-10-08T00:00:00\",\n \"preference\": \"primary\"\n }\n ],\n \"metadata\": {},\n \"id\": \"e17f9afb-ad01-4727-bd98-6664258decb0\"\n }"
},
"url": {
"raw": "persons/e17f9afb-ad01-4727-bd98-6664258decb0",
"host": [
"persons"
],
"path": [
"e17f9afb-ad01-4727-bd98-6664258decb0"
]
},
"description": "This request updates an existing persons resource.\n\nNote that the headers indicate what EEDM version of the resource is included in the message."
},
"response": []
},
{
"name": "Create a persons resource",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/vnd.hedtech.integration.v8+json"
},
{
"key": "Accept",
"value": "application/vnd.hedtech.integration.v8+json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"privacyStatus\": {\n \"privacyCategory\": \"unrestricted\"\n },\n \"names\": [\n {\n \"type\": {\n \"category\": \"legal\",\n \"detail\": {\n \"id\": \"5e59d3e4-61a8-4f61-9a18-05ae62a5b003\"\n }\n },\n \"fullName\": \"Mr. Alex Green\",\n \"title\": \"Mr.\",\n \"firstName\": \"Alex\",\n \"lastName\": \"Green\",\n \"preference\": \"preferred\"\n },\n {\n \"type\": {\n \"category\": \"personal\",\n \"detail\": {\n \"id\": \"6bf52ca3-3382-4f8e-9ae5-15b0b79f9c79\"\n }\n },\n \"fullName\": \"Alexander Green\",\n \"firstName\": \"Alexander\",\n \"lastName\": \"Green\"\n }\n ],\n \"dateOfBirth\": \"1988-09-23\",\n \"gender\": \"male\",\n \"maritalStatus\": {\n \"maritalCategory\": \"single\",\n \"detail\": {\n \"id\": \"332b98d6-9e6a-4313-80b4-ee5548d735aa\"\n }\n },\n \"citizenshipCountry\": \"USA\",\n \"metadata\": {},\n \"id\": \"4804cf37-c9d3-4658-9620-74db36e48221\"\n }"
},
"url": {
"raw": "persons",
"host": [
"persons"
]
}
},
"response": []
},
{
"name": "Publish single change-notification",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/vnd.hedtech.change-notifications.v2+json"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"resource\": {\n\t\t\"name\": \"buildings\",\n\t\t\"id\": \"fee12eb6-dae1-456b-a7c4-063458617478\",\n\t\t\"version\": \"application/vnd.hedtech.integration.v6+json\"\n\t},\n\t\"operation\": \"replaced\",\n\t\"contentType\": \"resource-representation\",\n\t\"content\": {\n\t\t\"code\": \"BLD1\",\n\t\t\"title\": \"Building 1\",\n\t\t\"description\": \"the first building\",\n\t\t\"id\": \"fee12eb6-dae1-456b-a7c4-063458617478\"\n\t}\n}"
},
"url": {
"raw": "https://integrate.elluciancloud.com/publish",
"protocol": "https",
"host": [
"integrate",
"elluciancloud",
"com"
],
"path": [
"publish"
]
}
},
"response": []
},
{
"name": "Publish array of change-notifications",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/vnd.hedtech.change-notifications.v2+json"
}
],
"body": {
"mode": "raw",
"raw": "[\n\t{\n\t\t\"resource\": {\n\t\t\t\"name\": \"buildings\",\n\t\t\t\"id\": \"fee12eb6-dae1-456b-a7c4-063458617478\",\n\t\t\t\"version\": \"application/vnd.hedtech.integration.v6+json\"\n\t\t},\n\t\t\"operation\": \"replaced\",\n\t\t\"contentType\": \"resource-representation\",\n\t\t\"content\": {\n\t\t\t\"code\": \"BLD1\",\n\t\t\t\"title\": \"Building 1\",\n\t\t\t\"description\": \"the first building\",\n\t\t\t\"id\": \"fee12eb6-dae1-456b-a7c4-063458617478\"\n\t\t}\n\t},\n\t{\n\t\t\"resource\": {\n\t\t\t\"name\": \"buildings\",\n\t\t\t\"id\": \"9d7c0f72-9eb4-4b76-83f1-e4a6a5fcab69\",\n\t\t\t\"version\": \"application/vnd.hedtech.integration.v6+json\"\n\t\t},\n\t\t\"operation\": \"replaced\",\n\t\t\"contentType\": \"resource-representation\",\n\t\t\"content\": {\n\t\t\t\"code\": \"BLD2\",\n\t\t\t\"title\": \"Building 2\",\n\t\t\t\"description\": \"the second building\",\n\t\t\t\"id\": \"9d7c0f72-9eb4-4b76-83f1-e4a6a5fcab69\"\n\t\t}\n\t}\n]"
},
"url": {
"raw": "https://integrate.elluciancloud.com/publish",
"protocol": "https",
"host": [
"integrate",
"elluciancloud",
"com"
],
"path": [
"publish"
]
}
},
"response": []
}
]
},
{
"name": "Banner Business Process API",
"item": [
{
"name": "sections-inquiry",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "sections-inquiry?termCode=202370",
"host": [
"sections-inquiry"
],
"query": [
{
"key": "termCode",
"value": "202370"
}
]
}
},
"response": []
},
{
"name": "qapi building-codes",
"request": {
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/vnd.hedtech.integration.v1.0.0+json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"code\": \"1BJSS\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://integrate.elluciancloud.com/qapi/building-codes",
"protocol": "https",
"host": [
"integrate",
"elluciancloud",
"com"
],
"path": [
"qapi",
"building-codes"
]
}
},
"response": []
},
{
"name": "building-codes",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "building-codes",
"host": [
"building-codes"
]
}
},
"response": []
}
]
},
{
"name": "Next Steps",
"item": [
{
"name": "GET Single Persons version-less",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "persons/00000000-0000-0000-0000-000000000000",
"host": [
"persons"
],
"path": [
"00000000-0000-0000-0000-000000000000"
]
}
},
"response": []
},
{
"name": "GET Single Persons version-specific",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/vnd.hedtech.integration.v12+json"
}
],
"url": {
"raw": "persons/00000000-0000-0000-0000-000000000000",
"host": [
"persons"
],
"path": [
"00000000-0000-0000-0000-000000000000"
]
}
},
"response": []
},
{
"name": "Read persons filter on credential",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "persons?criteria={\"credential\":{\"type\":\"colleaguePersonId\",\"value\":\"0000219\"}}",
"host": [
"persons"
],
"query": [
{
"key": "criteria",
"value": "{\"credential\":{\"type\":\"colleaguePersonId\",\"value\":\"0000219\"}}"
}
]
},
"description": "This API request is a GET to return a persons resource based on filtering for a specific credential."
},
"response": []
},
{
"name": "Read courses filter on title",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "courses?criteria={\"title\":\"Introduction to Psychology\"}",
"host": [
"courses"
],
"query": [
{
"key": "criteria",
"value": "{\"title\":\"Introduction to Psychology\"}"
}
]
},
"description": "This API request is a GET to return a collection of courses that match a value of the data model property \"title\".\n\nThe authoritative system may return a collection that contains all of the courses that match the filter or, if the dataset is large, a page. Included in the response headers will be information indicating how many total courses exist in the authoritative system and how many were returned in this response."
},
"response": []
},
{
"name": "Read courses filter by subject",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "courses?criteria={\"subject\":\"cc8fcbae-85d3-4acd-bf5d-e8d92f49e717\"}",
"host": [
"courses"
],
"query": [
{
"key": "criteria",
"value": "{\"subject\":\"cc8fcbae-85d3-4acd-bf5d-e8d92f49e717\"}"
}
]
},
"description": "This API request is a GET to return a collection of courses resources by a given subject (subject guid). \n\nThe authoritative system may return a collection that contains all of the courses available or, if the dataset is large, a page. Included in the response headers will be information indicating how many total courses exist in the authoritative system and how many were returned in this response."
},
"response": []
},
{
"name": "Read all persons paging 1",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "persons?offset=0&limit=100",
"host": [
"persons"
],
"query": [
{
"key": "offset",
"value": "0"
},
{
"key": "limit",
"value": "100"
}
]
},
"description": "This API request is a GET to return a collection of persons resources. \n\nIncluded as a query parameter is \"offset\", which is a 0-based indicator to the authoritative system to return a page of persons, beginning with the 1st record. The \"offset\" query parameter is important for paging through a large collection of data."
},
"response": []
},
{
"name": "Read all persons paging 2",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "persons?offset=100&limit=100",
"host": [
"persons"
],
"query": [
{
"key": "offset",
"value": "100"
},
{
"key": "limit",
"value": "100"
}
]
},
"description": "This API request is a GET to return a collection of persons resources. \n\nIncluded as a query parameter is \"offset\", which is a 0-based indicator to the authoritative system to return a page of persons, beginning with the 101st record. The \"offset\" query parameter is important for paging through a large collection of data."
},
"response": []
},
{
"name": "Read all persons paging 3",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "persons?offset=200&limit=100",
"host": [
"persons"
],
"query": [
{
"key": "offset",
"value": "200"
},
{
"key": "limit",
"value": "100"
}
]
},
"description": "This API request is a GET to return a collection of persons resources. \n\nIncluded as a query parameter is \"offset\", which is a 0-based indicator to the authoritative system to return a page of persons, beginning with the 201st record. The \"offset\" query parameter is important for paging through a large collection of data."
},
"response": []
},
{
"name": "GET institution-jobs filter for person",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "institution-jobs?criteria={\"endOn\":\"2013-01-31\",\"person\":\"08bb7310-0da7-4a0f-b5cc-4fcc516d4d8a\"}",
"host": [
"institution-jobs"
],
"query": [
{
"key": "criteria",
"value": "{\"endOn\":\"2013-01-31\",\"person\":\"08bb7310-0da7-4a0f-b5cc-4fcc516d4d8a\"}"
}
]
},
"description": "This request reads the institution-jobs resource with a filter for a specific person (guid).\n\nThe API will return a collection of institution-jobs for the given person guid."
},
"response": []
},
{
"name": "GET sections filter for academic-period and course",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "sections?criteria={\"academicPeriod\":{\"id\":\"17920c56-7a4c-4f00-9a39-4801b7e6fc58\"},\"course\":{\"id\":\"b5f58254-4d30-4052-ac8b-6d20898e232b\"}}",
"host": [
"sections"
],
"query": [
{
"key": "criteria",
"value": "{\"academicPeriod\":{\"id\":\"17920c56-7a4c-4f00-9a39-4801b7e6fc58\"},\"course\":{\"id\":\"b5f58254-4d30-4052-ac8b-6d20898e232b\"}}"
}
]
},
"description": "This request returns a collection of sections given a specific academic-period (guid) and course (guid)."
},
"response": []
},
{
"name": "Read persons filter on person-filters",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "persons?criteria={\"personFilter\":\"5305f3ee-a0a8-4893-9722-4c50ac9557a1\"}",
"host": [
"persons"
],
"query": [
{
"key": "criteria",
"value": "{\"personFilter\":\"5305f3ee-a0a8-4893-9722-4c50ac9557a1\"}"
}
]
},
"description": "This API request is a GET to return a collection of persons resources. \n\nThis request is filtered based on a person-filters guid, which should be preconfigured in the Authoritative system.\n\nThe authoritative system may return a collection that contains all of the courses available or, if the dataset is large, a page. Included in the response headers will be information indicating how many total persons exist in the authoritative system and how many were returned in this response."
},
"response": []
},
{
"name": "Read persons filter on role",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "persons?criteria={\"roles\":[{\"role\":\"student\"}]}",
"host": [
"persons"
],
"query": [
{
"key": "criteria",
"value": "{\"roles\":[{\"role\":\"student\"}]}"
}
]
},
"description": "This API request is a GET to return a collection of persons resources. \n\nThis request filters all persons records, telling the API to return only persons who are or have been a student."
},
"response": []
}
]
}
],
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{ethosToken}}",
"type": "string"
}
]
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"const tokenExpiresMinutes = 30",
"const now = Date.now();",
"const lastEthosAuthDate = pm.environment.get('ethosAuthDate');",
"const baseUrl = pm.environment.get(\"ethosIntegrationUrl\")",
"let expiresTime = !lastEthosAuthDate ? now : Date.parse(lastEthosAuthDate) + 1000*60*tokenExpiresMinutes;",
"",
"if (now + 1000 >= expiresTime) { ",
" console.log('getting a new token')",
" pm.sendRequest({",
" url: pm.environment.get(\"ethosIntegrationUrl\") + '/auth?expirationMinutes=' + tokenExpiresMinutes,",
" method: 'POST',",
" header: {",
" 'Accept': 'application/json',",
" 'Authorization': 'Bearer ' + pm.environment.get('ethosApiKey')",
" },",
" }, function (error, response) {",
" if (!error && response.code === 200) {",
" pm.environment.set(\"ethosToken\", response.text());",
" pm.environment.set('ethosAuthDate', new Date())",
" console.log('got a new token')",
" }",
" })",
"} else {",
" console.log('token still valid')",
"}",
"var hasAcceptHeader = false",
"",
"for (const header of pm.request.headers.all()) {",
" if (header.key == \"Accept\"){",
" hasAcceptHeader = true",
" }",
" if (header.key == \"Authorization\"){",
" console.log(\"Has it Authorizations\")",
" }",
"}",
"",
"if (!hasAcceptHeader) {",
" pm.request.headers.add({ ",
" key: \"Accept\",",
" value: \"application/json\" ",
" });",
"}",
"// console.log(pm.request.headers)",
"if (pm.request.url.toString().substring(0,4) !== \"http\") {",
" pm.request.url.update(baseUrl +\"/api/\"+ pm.request.url.toString() )",
"}",
"",
"pm.request.url=encodeURI(pm.variables.replaceIn(pm.request.url))"
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "ethosApiToken",
"value": "",
"type": "string"
}
]
}