Edited at

GitHub API で Create a Rlease をしようとしたら 422 Unprocessable Entity となった原因


使用したAPI

GitHub API - REST API v3


422 Unprocessable Entity になったコード

422の意味 => https://tools.ietf.org/html/rfc4918#section-11.2


index.js

const request = axios.create({

baseURL: data.url,
method: 'POST',
headers: {
Authorization: 'token ' + state.token,
},
data: {
tag_name: data.tag,
target_commitish: data.target,
name: data.title,
body: data.description,
draft: data.isDraft,
prerelease: data.isPreRelease
}
})
const response = await request('/releases')


正解


index.js

    data: {

"tag_name": data.tag,
"target_commitish": data.target,
"name": data.title,
"body": data.description,
"draft": data.isDraft,
"prerelease": data.isPreRelease
}
})


参考

https://developer.github.com/v3/repos/releases/#create-a-release

Screen Shot 2019-01-06 at 15.14.10.png