Comments (11)
BTW - Please feel free to tag me in issues from now on for some reason this didn't get on my radar. Looking into this now.
from ghapi.
Do you mind sharing the full code that created this error?
from ghapi.
Sure - though it is just the one-liner.
Given a card, for example this one:
https://github.com/orgs/jupyterhub/projects/1#card-15417167
with a card ID of 15417167
running this:
api.projects.move_card(15417167, 0)
results in HTTP422UnprocessableEntityError: HTTP Error 422: Unprocessable Entity
from ghapi.
friendly ping for @hamelsmu in case he isn't watching this repo :-)
from ghapi.
Sorry about that! Thanks for the reminder! This is currently on my backlog will try to get to this by next week hopefully
from ghapi.
No worries - in case this is helpful, I'd basically like to make this function work :-)
def sort_cards(column_id, labels, api):
"""Sort the cards in a GitHub Project column based on a list of labels.
Note: cards that do not directly point to a GitHub issue will be treated
like cards with issues that do not have one of the specified labels.
Parameters
----------
column_id: int
The unique ID of the column you'd like to sort
labels: list of strings
A list of strings to use in sorting your cards. The cards will be sorted
such that cards with first item of `labels` will come first.
"""
if api is None:
api = GhApi()
cards = api.projects.list_cards(column['id'])
for card in cards:
# If the card points to an issue, grab its list of labels
if "content_url" not in card:
continue
_, org, repo, _, num = card['content_url'].rsplit('/', 4)
issue_labels = api.issues.list_labels_on_issue(org, repo, num)
# Loop in reverse so that the first items in `labels` end up at the top
for label in labels[::-1]:
if any(label in ii['name'] for ii in issue_labels):
api.projects.move_card(str(card['id']), 0)
print(f"Moved card {card['id']}")
My use-case here is that I'd like to make it easier to "sort" the cards on a project board, based on the labels on issues they point to. The most obvious use for this is projects that have priority labels (so that priority:high
would be at the top)
from ghapi.
from ghapi.
In case this helps debug: it also seems like this is the case for moving columns to other positions as well - so perhaps it has something to do with putting the right information in the body of the API call. E.g., the move_card
API has this example:
curl \
-X POST \
-H "Accept: application/vnd.github.inertia-preview+json" \
https://api.github.com/projects/columns/cards/42/moves \
-d '{"position":"position"}'
And it sounds like the problem we're running into is in the generation of the -d '{"position":"position"}'
part of the call.
from ghapi.
@choldgraf I've been pulled away for something at work that is going to be taking me away from open source for a couple of months :( Perhaps @jph00 can help here
from ghapi.
Ah bummer, I will try to figure something out 👍
from ghapi.
ah I think I finally figured this out. The problem is that the position
key does not take a numerical argument (such as 0, 1, 2, etc). It takes a string like top
or bottom
. That's why it wasn't working.
This issue is resolved for me, and is really more of a GitHub Projects API documentation bug than here, so I'll close this
from ghapi.
Related Issues (20)
- api.repos.create_fork not finding repo but curl command working
- ProjectsV2? HOT 2
- pages does not work for list_packages_for_organization HOT 1
- UnicodeDecodeError on repos.download_tarball_archive HOT 1
- Set outputs is currently using syntax which is due to be deprecated
- feature: get dependabot alerts for enterprise/org
- Self documenting api object does not work as described in docs HOT 1
- Is this project still maintained? HOT 4
- v1.0.4 HOT 3
- Pagination Broke. ghapi 1.0.3 HOT 1
- Document leaky exceptions
- website documentation wrong for secret_scanning & dependabot
- Provide static API documentation HOT 1
- Missing orgs.list_saml_sso_authorizations and other enterprise endpoints HOT 1
- SyntaxWarning: invalid escape sequence HOT 2
- Add ability to read token reported by `gh auth token` HOT 1
- Pagination does not work for api.search.code HOT 2
- Remove `pip` from dependencies HOT 2
- feature request: app authentication support
- How can I get the HTTP response status code after calling the APIs?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ghapi.