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

fix: only add query params to GET requests #21

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

cellomatt
Copy link

Description

This SDK currently checks the HTTP method of a given request to see whether it should add the request Options as query parameters (as opposed to in the body of the request). Unfortunately, it's currently targeted at any endpoint that does not have a POST method rather than to only the relevant GET requests. This means we have some PUT requests (like updating user preferences) which are passing query parameters unnecessarily.

Copy link

@mattmikolay mattmikolay left a comment

Choose a reason for hiding this comment

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

@@ -189,7 +189,7 @@ private Uri BuildUri(KnockRequest request)
builder.Append(ApiBaseURL);
builder.Append(request.Path);

if (request.Method != HttpMethod.Post && options != null)
if (request.Method == HttpMethod.Get && options != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to confirm: are we 100% about this change? What about DELETE requests? It's generally expected that deletes use query params > request bodies iirc

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I was on the fence with how to treat this here given future state of generated SDKs from a spec.

I double-checked all of our documented endpoints, and we currently only use query params on GET-method endpoints except for two PUT endpoints (for Slack and Teams, to revoke access to a given access_token), both of which are not currently in this SDK.

I started out thinking we should add cases for those requests but then realized the methods didn't exist in the SDK so I opted for the simpler solution. Right now, CreateHttpRequestMessage puts any non-GET request's Options in the request body, so current state of the SDK will duplicate Options in body + query params for any request that isn't a POST or GET.

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.

3 participants