question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In pulls.get, getting error 'mediaType' does not exist in type 'PullsGetParams'

See original GitHub issue

Bug Report

Current Behavior When trying to typescript-compile the below code, getting Argument of type '{ owner: string; repo: string; pull_number: any; mediaType: { format: string; }; }' is not assignable to parameter of type 'PullsGetParams'.

import { Application } from 'probot' // eslint-disable-line no-unused-vars

export = (app: Application) => {
  app.on('pull_request.opened', async (context) => {
    const issue = context.issue()
    const pr = await context.github.pulls.get({
      owner: issue.owner,
      repo: issue.repo,
      pull_number: issue.number,
      mediaType: {
        format: 'diff'
      }
    })

    console.error(pr)
  })
}

Expected behavior/code Should be able to compile and run, according to docs from @octokit/rest: https://octokit.github.io/rest.js/ Excerpt:

const { data: diff } = await octokit.pulls.get({
  owner: "octokit",
  repo: "rest.js",
  pull_number: 123,
  mediaType: {
    format: "diff"
  }
});

Environment

  • Probot version(s): v9.5.0
  • Node/npm version: node v10.16.0
  • OS: macOS

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
qnnguyen17commented, Sep 23, 2019

The problem might be pull_number: any. Can you try this?

    pull_number: issue.number as number

Thanks for taking a look! I changed the code to your suggestion:

    await context.github.pulls.get({
      owner: issue.owner,
      repo: issue.repo,
      pull_number: issue.number as number,
      mediaType: {
        format: 'diff'
      }
    })

And I’m getting the following error:

No overload matches this call.
  Overload 1 of 2, '(params?: PullsGetParamsDeprecatedNumber | undefined): Promise<Response<PullsGetResponse>>', gave the following error.
    Argument of type '{ owner: string; repo: string; pull_number: number; mediaType: { format: string; }; }' is not assignable to parameter of type 'PullsGetParamsDeprecatedNumber'.
      Object literal may only specify known properties, and 'pull_number' does not exist in type 'PullsGetParamsDeprecatedNumber'.
  Overload 2 of 2, '(params?: PullsGetParams | undefined): Promise<Response<PullsGetResponse>>', gave the following error.
    Argument of type '{ owner: string; repo: string; pull_number: number; mediaType: { format: string; }; }' is not assignable to parameter of type 'PullsGetParams'.
      Object literal may only specify known properties, and 'mediaType' does not exist in type 'PullsGetParams'.
0reactions
qnnguyen17commented, Sep 24, 2019

Thank you so much for the quick response and fix!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting not supported media type error - json - Stack Overflow
Change your Content-Type in Postman to application/json . Click on the Headers button to do so. Also you are not producing json in...
Read more >
415 Unsupported Media Type - KeyCDN Support
A 415 Unsupported Media Type error occurs when the origin server refuses a particular request since the resource is in a format that...
Read more >
APIKit "Unsupported media type" error - MuleSoft Help Center
This type of Error occurs when you define the MediaType or MimeType or Format for you resource to accept application/Json but while calling...
Read more >
C# API Media type not supported - Error 1124
Hi Guys, Trying API for first time. I am able to do GET sheet details successfully.
Read more >
Web API 415: Unsupported Media Type - Microsoft Q&A
Web API 415: Unsupported Media Type. How can I support two content types for an endpoint - application/x-www-form-urlencoded
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found