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

Project card creation not working for GithubEnterprise #1094

Open
k3boxers opened this issue Jun 10, 2022 · 1 comment
Open

Project card creation not working for GithubEnterprise #1094

k3boxers opened this issue Jun 10, 2022 · 1 comment

Comments

@k3boxers
Copy link

When trying to create a card in a Github Enterprise repository the url that is built isn't for the Enterprise server, but for api.github.com.

Creating a project and columns worked fine, trying to read columns however had the same issue.

Since it is going to the github, where my project doesn't exist and I'm not authenticated I get the following error:

/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'api.github.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/github3/structs.py", line 120, in next
    return self.__next__()
  File "/usr/local/lib/python3.9/site-packages/github3/structs.py", line 106, in __next__
    return next(self.__i__)
  File "/usr/local/lib/python3.9/site-packages/github3/structs.py", line 76, in __iter__
    json = self._get_json(response)
  File "/usr/local/lib/python3.9/site-packages/github3/structs.py", line 109, in _get_json
    return self._json(response, 200)
  File "/usr/local/lib/python3.9/site-packages/github3/models.py", line 156, in _json
    raise exceptions.error_for(response)
github3.exceptions.AuthenticationFailed: 401 Bad credentials

I believe it is because it is referencing self._github_url rather than self._api in projects.py, but I was unable to fix in the python debugger.

253     def create_card_with_content_id(self, content_id, content_type):
254         """Create a content card in this project column.
255 
256         :param int content_id:
257             (required), the ID of the content
258         :param str content_type:
259             (required), the type of the content
260         :returns:
261             the created card
262         :rtype:
263             :class:`~github3.projects.ProjectCard`
264         """
265         if not content_id or not content_type:
266             return None
267 
268         url = self._build_url(
269             'projects/columns',
270             str(self.id),
271             'cards',
272             base_url=self._github_url
273         )
274         json = None
275         data = {'content_id': content_id, 'content_type': content_type}
276         json = self._json(self._post(
277             url, data=data, headers=Project.CUSTOM_HEADERS), 201)
278         return self._instance_or_null(ProjectCard, json)
@k3boxers
Copy link
Author

I verified the issue is with the ._github_url. If I change that to point to my enterprise server col._github_url = 'https://api.github.[MYHOST] it works. I would do a pull request, but I don't know what the best way to fix it is, since I don't think it is a direct replacement with col._api.

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

No branches or pull requests

1 participant