简体   繁体   English

GITHub API文件上传问题

[英]GITHub API Issue with file upload

I am trying to upload file to GitHub via GITHub API ( http://developer.github.com/v3/repos/contents/ ). 我正在尝试通过GITHub API( http://developer.github.com/v3/repos/contents/ )将文件上传到GitHub。 Somehow I am not able to upload file. 不知怎的,我无法上传文件。 When I tried to upload existing file it gave me message "{\\"message\\":\\"refs/heads/master expected to be at ee1cd720841a4b5b06a8339c333c56b1748e66f9\\",\\"documentation_url\\":\\" http://developer.github.com/v3/repos/contents/ \\"}". 当我尝试上传现有文件时,它给我发出消息“{\\”message \\“:\\”refs / heads / master预计位于ee1cd720841a4b5b06a8339c333c56b1748e66f9 \\“,”documentation_url \\“:\\” http://developer.github。 com / v3 / repos / contents / \\“}”。 When I went to github and tried to delete file using website it gave me below error. 当我去github尝试使用网站删除文件时,它给了我以下错误。 I can do workaround with reset head to previous version and move on. 我可以使用重置头到先前版本进行解决方法并继续。 But I am trying to understand what caused this behavior and how can I prevent same in future. 但我试图了解导致这种行为的原因以及我将来如何防止这种行为。 Neither Google nor Github Help was able to answer me so looking for something from community. 谷歌和Github帮助都没有能够回答我,所以从社区寻找一些东西。 Thanks for looking into it. 感谢您对此进行调查。 在此输入图像描述

As Ivan suggested, if we try to create/update files using quick succession using API it causes mentioned behavior. 正如Ivan建议的那样,如果我们尝试使用API​​快速连续创建/更新文件,则会导致上述行为。 Till issue is fixed we can workaround this by making thread sleep between two request. 直到问题得到解决我们可以通过在两个请求之间进行线程休眠来解决此问题。 I hope it will help someone. 我希望它能帮助别人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM