Home > database >  Problem with python Pastebin API: Bad API request
Problem with python Pastebin API: Bad API request

Time:05-03

you see, I have been looking at the pastebin api and I tried to make a post request with python, what happens is that I receive the error Bad API request, invalid api_dev_key, when the dev_key api is correct. I have even created another account to test if the error was shared, and it was.

I saw that someone had a similar error, and I solve it by changing http to https, I tried it but it still doesn't work, here is the code:

import requests

dev_key = "--The Dev Key"
url = "https://pastebin.com/api/api_post.php"

def PostPastebinAPI(args):
    Lista_Errores = [
        "Bad API request, invalid api_option",
        "Bad API request, invalid api_dev_key",
        "Bad API request, maximum number of 25 unlisted pastes for your free account",
        "Bad API request, maximum number of 10 private pastes for your free account",
        "Bad API request, api_paste_code was empty",
        "Bad API request, maximum paste file size exceeded",
        "Bad API request, invalid api_paste_expire_date",
        "Bad API request, invalid api_paste_private",
        "Bad API request, invalid api_paste_format",
        "Bad API request, invalid api_user_key",
        "Bad API request, invalid or expired api_user_key",
        "Bad API request, you can't add paste to folder as guest"
    ]
    response = requests.post(url, args)
    
    for error in Lista_Errores:
        if response.text == error:
            return "Error en PastebinAPIPost: \n" "{}".format(error)
    
    return response.text
    
Post = PostPastebinAPI({
    "dev_key_api": "2gpdDFVdUNeze0fSnB6b9-FZJ8g2tlYV",
    "api_option": "paste",
    "api_paste_code": "Test"
})
print(Post)

CodePudding user response:

try changing it to api_dev_key?

Post = PostPastebinAPI({
    "api_dev_key": "<YOUR API KEY HERE>",
    "api_option": "paste",
    "api_paste_code": "Test"
})
  • Related