Pastebin always returns 422

Asked 2 years ago, Updated 2 years ago, 429 views

I registered my account with Pastebin and tried to use the API, but
Bad API request, invalid api_dev_key shows no sign of success.
The API key does not contain spaces, and I copied them from the page, so there is no mistake.

import*asqs from 'querystring'
import* as fetch from 'node-fetch'

~~~

constquery=qs.stringify({
  api_option: 'paste',
  api_dev_key: 'Copy API Key',
  api_paste_name: `Tai-tori',
  api_paste_format: 'javascript',
  api_paste_code: 'Code',
})

const url = wait(
  wait fetch.default(`https://pastebin.com/api/api_post.php?${query}`, {
    method: 'POST',
  })
) .text( )

console.log(url)

Expected Results

https://pastebin.com/xxxxxx

Actual Results

Bad API request, invalid api_dev_key

node.js typescript webapi

2022-09-30 21:49

1 Answers

method:POST, but the format appears to be HTTP GET. For POST, the body parameter should be ${query}.`

Thank you metropolis.
That's right. It was solved by passing it to body.


2022-09-30 21:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.