Skip to content
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

Don't add trailing / in api calls #231

Merged

Conversation

daveneeley
Copy link
Contributor

@daveneeley daveneeley commented Jan 21, 2020

Always appending / to the resource can cause some POST requests for new resources to fail when using _callAPI / _buildRequestURI.

PR Summary

Fixes #230

PR Checklist

No new help or unit tests to write.

Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Uri -eq "https://dev.azure.com/test/test/_apis/wit/workitemtypes/?api-version=$([VSTeamVersions]::Core)"
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 2 -ParameterFilter {
$Uri -eq "https://dev.azure.com/test/test/_apis/wit/workitemtypes?api-version=$([VSTeamVersions]::Core)"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Calling this test out - the mock was only asserted once before these changes because each call built the URL differently. Now they both build it the same way.

@daveneeley daveneeley changed the title Build request uri post Don't add trailing / in api calls Jan 21, 2020
@daveneeley
Copy link
Contributor Author

As it turns out, this change did not have an effect on the api call I was trying to use. I've filed a bug report against Azure DevOps.

I do think it's a good change however. It's more consistent with the API docs to remove the / unless an id of some kind is included in the request.

@DarqueWarrior
Copy link
Collaborator

Thanks for the update and support. I will look into merging this PR this week.

@DarqueWarrior DarqueWarrior merged commit 86a45ea into MethodsAndPractices:master Feb 11, 2020
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.

_buildRequestURI should only append / after resource when ID is set
2 participants