github / maven-plugins

Official GitHub Maven Plugins
MIT License
587 stars 197 forks source link

create refs fails with encrypted error "Invalid request.\n\nFor 'links/0/schema', nil is not an object" #137

Open reachvimalm opened 6 years ago

reachvimalm commented 6 years ago

I am using REST API to create branch on my fork. but it throws weird error "Invalid request.\n\nFor 'links/0/schema', nil is not an object." I am using python session.post Request

[https://mygit.com/api/v3/repos/vimal/myproj/git/refs] ref [refs/heads/readme] {'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'User-Agent': 'python-requests/2.18.4', 'sha': u'fc20403521d0bcea35b3b14a3622ffdd5d0359bc', 'Connection': 'keep-alive', 'ref': 'refs/heads/readme', 'Authorization': 'token 123x'}

Response

{u'documentation_url': u'https://developer.github.com/enterprise/2.12/v3/git/refs/#create-a-reference', u'message': u"Invalid request.\n\nFor 'links/0/schema', nil is not an object."}

jothikanth commented 5 years ago

@reachvimalm , There is some problem with the data you are posting. The API is not able to interpret your data properly. Since you are using python requests module, I suggest using the json keyword when doing a requests.post()

hckr commented 3 years ago

I got such an error from GitHub API when I didn't send any POST data.

VickyWinner commented 3 years ago

I am getting the same error. @reachvimalm @hckr were you able resolve it?

[tkn-task] ←[96mLine |
[tkn-task] ←[96m  72 | ←[0m     ←[96mInvoke-RestMethod -Headers $headers -uri $URI -Body $json -Method←[0m …
[tkn-task] ←[96m     | ←[91m     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[tkn-task] ←[91m←[96m     | ←[91m{"message":"Invalid request.\n\nFor 'links/0/schema', nil is
[tkn-task] ←[96m     | ←[91mnot an
[tkn-task] ←[96m     | ←[91mobject.","documentation_url":"https://docs.github.com/enterprise/2.22/rest/reference/repos#create-a-commit-comment"}
[tkn-task] ←[0m
reachvimalm commented 3 years ago

I was able to solve it. My request was not correct.

hckr commented 3 years ago

My request also wasn't correct, it lacked message body.

amanaation commented 2 years ago

@jothikanth

Hey!! I also have same issue while trying to dispatch the Github Actions via the Github API. Following is my post request: res = requests.post(url, auth=HTTPBasicAuth(self.username, self.password), params=params) Following are the message details :

URL = https://api.github.com/repos/amanaation/repo_name/actions/workflows/sampleid123/dispatches and the credentials. Any help is really appreciated. I am stuck in this issue for hours.

I am getting the following credentials :

RESPONSE : <Response [422]> {'message': "Invalid request.\n\nFor 'links/0/schema', nil is not an object.", 'documentation_url': 'https://docs.github.com/rest/reference/actions#create-a-workflow-dispatch-event'}