-
Notifications
You must be signed in to change notification settings - Fork 665
Replace RestSharp with HttpClient to eliminate dependency conflicts #16841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: QilongTang <[email protected]>
Co-authored-by: QilongTang <[email protected]>
Co-authored-by: QilongTang <[email protected]>
| client.Timeout = TimeSpan.FromSeconds(7); | ||
| client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tkn); | ||
|
|
||
| var content = new StringContent(requestJSON, Encoding.UTF8, "application/json"); |
| { | ||
| var fulfillmentUrl = $"/v1/collections/{collectionId}/exchanges/{exchangeContainerId}/fulfillments:start"; | ||
| RestRequest startFulfillmentRequest = new RestRequest(fulfillmentUrl); | ||
| var startFulfillmentRequest = new HttpRequestMessage(HttpMethod.Post, fulfillmentUrl); |
| { | ||
| var endFulfillmentUrl = $"/v1/collections/{collectionId}/exchanges/{exchangeContainerId}/fulfillments/{fulfillmentId}:finish"; | ||
| RestRequest endFulfillmentRequest = new RestRequest(endFulfillmentUrl); | ||
| var endFulfillmentRequest = new HttpRequestMessage(HttpMethod.Post, endFulfillmentUrl); |
| var createExchangeURL = $"/v1/collections/{CollectionId}/exchanges"; | ||
| RestRequest createExchangeRequest = new RestRequest(createExchangeURL); | ||
| createExchangeRequest.AddStringBody(exchangeBody, ContentType.Json); | ||
| var createExchangeRequest = new HttpRequestMessage(HttpMethod.Post, createExchangeURL); |
|
|
||
| RestRequest createBinaryRequest = new RestRequest(createBinaryAssetUrl); | ||
| createBinaryRequest.AddStringBody(createBinaryBody, ContentType.Json); | ||
| var createBinaryRequest = new HttpRequestMessage(HttpMethod.Post, createBinaryAssetUrl); |
| var base64CompressedBuffer = ConvertDynToBase64(filePath); | ||
| using (var fileUploadClient = new HttpClient()) | ||
| { | ||
| var uploadBinaryRequest = new HttpRequestMessage(HttpMethod.Put, binaryUploadUrl); |
|
|
||
| RestRequest finishBinaryUploadRequest = new RestRequest(finishBinaryUploadUrl); | ||
| finishBinaryUploadRequest.AddStringBody(finishBinaryUploadBody, ContentType.Json); | ||
| var finishBinaryUploadRequest = new HttpRequestMessage(HttpMethod.Post, finishBinaryUploadUrl); |
|
|
||
| RestRequest syncAssetRequest = new RestRequest(syncAssetUrl); | ||
| syncAssetRequest.AddStringBody(syncAssetRequestBody, ContentType.Json); | ||
| var syncAssetRequest = new HttpRequestMessage(HttpMethod.Post, syncAssetUrl); |
|
@copilot Fix build error IDSDKManager.cs(14,33): error CS0535: 'IDSDKManager' does not implement interface member 'IOAuth2AuthProvider.SignRequest(ref RestRequest, RestClient)' |
…stSharp migration Co-authored-by: QilongTang <[email protected]>
Fixed in commit 27758e7. Removed |
|
@zeusongit suggested to include Greg in this conversation. I believe the current PR is hitting that point. It does seem that same migration but in Greg would make more sense |
RestSharp dependency causes version conflicts between Dynamo, Revit hosts, and package authors. Migrated to built-in .NET HttpClient.
Changes
HTTP client replacements:
NodeAutoCompleteSearchViewModel.cs- ML autocomplete API calls (7s timeout viaHttpClient.Timeout)NodeAutoCompleteBarViewModel.cs- Generic autocomplete API calls with Bearer token authDynamoMLDataPipeline.cs- Data pipeline POST/PUT operations with Bearer token authDynamoPackagesAnalyzer/DynamoPackagesSource.cs- Package download GET requests with async/awaitProject references:
API changes:
IOAuth2AuthProviderinterface implementation fromIDSDKManager(interface required RestSharp types)IDSDKManager.SignRequest()andIDSDKManager.LoginRequest()methods (unused and required RestSharp types)GetAccessToken()fromIOAuth2AccessTokenProviderremains as the API for obtaining bearer tokensExample
Before:
After:
JSON serialization continues using Newtonsoft.Json for consistency.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.