Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何使用API更新GIT中的文件-给出错误404错误_Angular_Git_Github_Httpclient_Github Api - Fatal编程技术网

Angular 如何使用API更新GIT中的文件-给出错误404错误

Angular 如何使用API更新GIT中的文件-给出错误404错误,angular,git,github,httpclient,github-api,Angular,Git,Github,Httpclient,Github Api,我试图使用API更新GIT中的文件,并得到错误代码404 updateServersonGIT(servList: string): Observable<Array<any>> { return this.http.put<Array<any>>("https://api.github.com/repos/amshreyas/servers/contents/serv.json",{"Authorization" : "token <

我试图使用API更新GIT中的文件,并得到错误代码404

updateServersonGIT(servList: string): Observable<Array<any>> {
    return this.http.put<Array<any>>("https://api.github.com/repos/amshreyas/servers/contents/serv.json",{"Authorization" : "token <my token>",servList}).pipe(catchError(this.handleError));
  }
updateServersonGIT(servList:string):可观察{
返回此.http.put(“https://api.github.com/repos/amshreyas/servers/contents/serv.json,{“Authorization”:“token”,servList}.pipe(catchError(this.handleError));
}
我已经生成了oAuth令牌。
请告知

它可能会失败,因为您没有在文档中指定要与
PUT一起使用的必填字段:

您尤其需要确保提供以下字段:

  • 消息
    -要与更改关联的提交消息
  • committer
    -包含提交者名称和电子邮件的JSON对象
  • content
    新文件内容的base64编码字符串
以下是文档中的一个示例:

{
  "message": "my commit message",
  "committer": {
    "name": "Monalisa Octocat",
    "email": "octocat@github.com"
  },
  "content": "bXkgbmV3IGZpbGUgY29udGVudHM="
}
我不清楚是否发生了这种情况,因为该示例没有提供足够的信息在本地为其他人运行


如果您的令牌没有设置
public\u repo
的话,它也可能会失败。

我没有在http.put方法中正确地放置数据和HttpOptions。现在已经解决了。谢谢