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

Updating file is not possible #354

Closed
GJL opened this issue Apr 3, 2017 · 2 comments
Closed

Updating file is not possible #354

GJL opened this issue Apr 3, 2017 · 2 comments

Comments

@GJL
Copy link

GJL commented Apr 3, 2017

Updating a file is not possible with GHRepository.createContent(...). None of the methods accept the required sha argument. See https://developer.github.com/enterprise/2.9/v3/repos/contents/#update-a-file

sha string Required. The blob SHA of the file being replaced.

Full stacktrace:

Caused by: org.kohsuke.github.HttpException: {"message":"Invalid request.\n\n\"sha\" wasn't supplied.","documentation_url":"https://developer.github.com/enterprise/2.9/v3/repos/contents/"}
	at org.kohsuke.github.Requester.handleApiError(Requester.java:654)
	at org.kohsuke.github.Requester._to(Requester.java:283)
	at org.kohsuke.github.Requester.to(Requester.java:224)
	at org.kohsuke.github.GHRepository.createContent(GHRepository.java:1343)
	at org.kohsuke.github.GHRepository.createContent(GHRepository.java:1325)
	[...]
	... 7 more
Caused by: org.kohsuke.github.HttpException: Server returned HTTP response code: 422, message: 'Unprocessable Entity' for URL: [...]
	at org.kohsuke.github.Requester.parse(Requester.java:612)
	at org.kohsuke.github.Requester._to(Requester.java:262)
	... 11 more
Caused by: java.io.IOException: Server returned HTTP response code: 422 for URL: [...]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
	at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1889)
	at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1884)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1883)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1456)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
	at org.kohsuke.github.Requester.parse(Requester.java:596)
	... 12 more
Caused by: java.io.IOException: Server returned HTTP response code: 422 for URL: [...]
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1839)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
	at org.kohsuke.github.Requester.parse(Requester.java:586)
	... 12 more
@vishmegh88
Copy link

I am facing the same issue with Kohsuke.

@bitwiseman
Copy link
Member

This seems fixed. You get a GHContent and then you can call update on it.

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

3 participants