Github API - Create a release "body" is too big

Hello,

I am using the Github API to create a new release in my repository. First, I make a request to generate release notes at /repos/{owner}/{repo}/releases/generate-notes. Then, I include the body from that response in my request to /repos/{owner}/{repo}/releases/generate-notes. When I do, I get the following response:

Error: POST was not successful StatusCode: 422 - Response Data: {"message":"Invalid request.\n\nFor 'links/0/schema', \"body\" is not an object.","documentation_url":"https://docs.github.com/rest/reference/repos#create-a-release"}

However if I do not use the release notes from the first API request and instead just use something simple in the body of /repos/{owner}/{repo}/releases, then the request does work. Because the error message that is returned from /repos/{owner}/{repo}/releases is not helpful at all, I assume that the problem is that my generated release notes are too large, and that fails some validation.

Is this assumption correct? If so is there any workaround for this? Thanks

Can you provide sample code? I’m having trouble following.

Sure, here is some code. This is not exactly what I am doing since I have a custom solution that I am running in a script, but this is the basic idea.

const octokit = new Octokit({
  auth: 'personal-access-token123'
})

// Request to generate the release notes for the code between the release tags of v1.0.0 and v1.0.1
// `body` here is a large string of text (~9kb) since my team has made a lot of pull requests in between releases
const { body} = await octokit.request('POST /repos/{owner}/{repo}/releases/generate-notes', {
  owner: 'OWNER',
  repo: 'REPO',
  target_commitish: '12345',
  tag_name: 'v1.0.1',
  previous_tag_name: 'v1.0.0,
  configuration_file_path: '.github/custom_release_config.yml'
});

// This request fails with the `422` error code
await octokit.request('POST /repos/{owner}/{repo}/releases', {
  owner: 'OWNER',
  repo: 'REPO',
  target_commitish: '12345',
  tag_name: 'v1.0.01,
  name: 'Release v1.0.1',
  body,  // This is the body retrieved from the previous request
  draft: false,
  prerelease: true,
  generate_release_notes: false
})

// This request works just fine
// The `body` is just a small string
await octokit.request('POST /repos/{owner}/{repo}/releases', {
  owner: 'OWNER',
  repo: 'REPO',
  target_commitish: '12345',
  tag_name: 'v1.0.01,
  name: 'Release v1.0.1',
  body: 'Some really small description',
  draft: false,
  prerelease: true,
  generate_release_notes: false
})

Hope this helps make it a little clearer what I am trying to accomplish. Let me know if you need more details and I’ll be happy to provide.