Skip to content

Updating file is not possible #354

@GJL

Description

@GJL

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions