@@ -41,29 +41,48 @@ public static OrganizationExportResponse CreateBulkExportRequest(
4141 Type = "organization_memberships_export" ,
4242 } ;
4343
44- var exportResponse = bulkExportsApi . CreateUserListExport ( organizationId , organizationExportRequest ) ;
44+ var exportResponse = bulkExportsApi . CreateUserListExportWithHttpInfo ( organizationId , organizationExportRequest ) ;
45+ exportResponse . Headers . TryGetValue ( "X-RateLimit-Remaining" , out string remaining ) ;
46+ exportResponse . Headers . TryGetValue ( "X-RateLimit-Reset" , out string reset ) ;
47+
48+ if ( reset != null && remaining != null )
49+ {
50+ DateTime resetDate = DateTimeOffset . FromUnixTimeSeconds ( long . Parse ( reset ) ) . UtcDateTime ;
51+ Console . WriteLine ( "API calls remaining: " + remaining ) ;
52+ Console . WriteLine ( "Next Reset: " + resetDate ) ;
53+ }
54+
4555 //ds-snippet-end:Admin3Step3
4656
4757 //ds-snippet-start:Admin3Step4
4858 int retryCount = 5 ;
4959
5060 while ( retryCount >= 0 )
5161 {
52- if ( exportResponse . Results != null )
62+ if ( exportResponse . Data . Results != null )
5363 {
54- GetUserData ( accessToken , exportResponse . Results . FirstOrDefault ( ) . Url , filePath ) ;
64+ GetUserData ( accessToken , exportResponse . Data . Results . FirstOrDefault ( ) . Url , filePath ) ;
5565 break ;
5666 }
5767 else
5868 {
5969 -- retryCount ;
6070 System . Threading . Thread . Sleep ( 5000 ) ;
61- exportResponse = bulkExportsApi . GetUserListExport ( organizationId , exportResponse . Id ) ;
71+ exportResponse = bulkExportsApi . GetUserListExportWithHttpInfo ( organizationId , exportResponse . Data . Id ) ;
72+ exportResponse . Headers . TryGetValue ( "X-RateLimit-Remaining" , out remaining ) ;
73+ exportResponse . Headers . TryGetValue ( "X-RateLimit-Reset" , out reset ) ;
74+
75+ if ( reset != null && remaining != null )
76+ {
77+ DateTime resetDate = DateTimeOffset . FromUnixTimeSeconds ( long . Parse ( reset ) ) . UtcDateTime ;
78+ Console . WriteLine ( "API calls remaining: " + remaining ) ;
79+ Console . WriteLine ( "Next Reset: " + resetDate ) ;
80+ }
6281 }
6382 }
6483
6584 //ds-snippet-end:Admin3Step4
66- return exportResponse ;
85+ return exportResponse . Data ;
6786 }
6887
6988 /// <summary>
@@ -92,6 +111,15 @@ private static void GetUserData(string accessToken, string csvUrl, string filePa
92111 request . AllowWriteStreamBuffering = false ;
93112
94113 response = ( HttpWebResponse ) request . GetResponse ( ) ;
114+ string remaining = response . Headers . Get ( "X-RateLimit-Remaining" ) ;
115+ string reset = response . Headers . Get ( "X-RateLimit-Reset" ) ;
116+
117+ if ( reset != null && remaining != null )
118+ {
119+ DateTime resetDate = DateTimeOffset . FromUnixTimeSeconds ( long . Parse ( reset ) ) . UtcDateTime ;
120+ Console . WriteLine ( "API calls remaining: " + remaining ) ;
121+ Console . WriteLine ( "Next Reset: " + resetDate ) ;
122+ }
95123
96124 Stream stream = response . GetResponseStream ( ) ;
97125
0 commit comments