Skip to content

Use credentials in Structure Query and add endpoint for testing it#630

Open
nbeatty-gpa wants to merge 10 commits into
masterfrom
XDA-69
Open

Use credentials in Structure Query and add endpoint for testing it#630
nbeatty-gpa wants to merge 10 commits into
masterfrom
XDA-69

Conversation

@nbeatty-gpa
Copy link
Copy Markdown
Contributor

For XDA-69 - previous method of sending a structure query and processing the response did not throw an exception for unsuccessful HTTP responses, and would attempt to read unsuccessful responses as CSV. Now that credentials are being used, GetStructureQuery is changed to use configurable credentials and check for successful response before parsing the response.

An endpoint is added as well to check the success of Structure Queries through System Center.

@nbeatty-gpa nbeatty-gpa requested a review from clackner-gpa May 13, 2026 13:17
@nbeatty-gpa nbeatty-gpa force-pushed the XDA-69 branch 5 times, most recently from 846b4a7 to 2bb7ccc Compare May 18, 2026 16:11

string query = @"
SELECT TOP (1) *,
(SELECT assetLocation.LocationID FROM AssetLocation assetLocation WHERE assetLocation.AssetID = asset.ID) AS LocationID
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will return many if the Asset is tied to multiple locations and throw an exception

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed 3fbf8ec

request.UseDefaultCredentials = true;
return true;
string responseContent = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
Log.Error($"Structure query received 'InternalServerError' response: {responseContent}");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should Log the error if you throw the exception so no need to do both

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed 3c04002

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants