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

Recover status code after request #188

Closed
GuillemBarroso opened this issue Oct 26, 2022 · 6 comments · Fixed by #194
Closed

Recover status code after request #188

GuillemBarroso opened this issue Oct 26, 2022 · 6 comments · Fixed by #194

Comments

@GuillemBarroso
Copy link

Hi!

I am using gidgethub to create a bot within a GitHub App. I am struggling when checking whether a user is member of a certain organization, see GitHub documentation for this call.

From what I understood, gh.getitem only returns the body of the request. However, the call mentioned above only returns a status code as a response (either 204, 302 or 404). Thus, I am not sure how to recover this status code after using await gh.getitem(url, oauth_token=oauth_token).

Please, let me know if I am misunderstanding something. Thanks!

@brettcannon
Copy link
Collaborator

brettcannon commented Oct 26, 2022

Unfortunately, when I designed the API, I either didn't know about that part of the API or it didn't exist yet. 😅 I would be okay with adding a getstatus() API endpoint in gidgethub.abc. It could probably be done by refactoring the details in _make_request() that build everything together to pass to _request() and then calling _request() directly.

@GuillemBarroso
Copy link
Author

Thank you for the quick response. I might have found a workaround by listing all the members of an organization, a request that does provide a body as a response. However, I'm not too sure what approach would be the best for my case. I'll keep assessing both options. Thanks!

@offbyone
Copy link
Contributor

@brettcannon out of curiosity what would be your thought about augmenting _make_request() to return the status code? It's an internal method, by the naming, and the call sites already often ignore one of the return values.

offbyone added a commit to offbyone/gidgethub that referenced this issue Apr 24, 2023
This now supports API methods whose responses are expressed in a status
code, such as `/orgs/{org}/members/{username}` to determine if a group
contains a specific user.

/cc gidgethub#188
@brettcannon
Copy link
Collaborator

out of curiosity what would be your thought about augmenting _make_request() to return the status code?

Without seeing how it makes the code look I don't have a specific opinion either way.

@offbyone
Copy link
Contributor

offbyone commented May 3, 2023

Coincidentally, there's this pull request right over there 👉 ;)

@brettcannon
Copy link
Collaborator

Coincidentally, there's this pull request right over there 👉 ;)

Oh, I know, but I'm still digging myself out from all of my GitHub notifications, so I'm treating everything in isolation in case it takes a while to get to your PR. 😁

brettcannon pushed a commit that referenced this issue May 4, 2023
This now supports API methods whose responses are expressed in a status
code, such as `/orgs/{org}/members/{username}` to determine if a group
contains a specific user.

Closes #188

Co-authored-by: Mariatta Wijaya <Mariatta@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants