Search code examples
c#pastebin

Error with pastebin API: Bad API request, invalid api_paste_format


I am using this API, and this is my program.

Whenever I try to send a paste to pastebin I get an error on line 77 in the API:

return resp;

I'm not sure what I should do to enable the post to send successfully.

A first chance exception of type 'PasteBin.PasteBinApiException' occurred in WinForms_Run.exe Additional information: Bad API request, invalid api_paste_format

Any help is much appreciated.


Solution

  • The exception you're encountering is actually on the line before return resp.

    You should put a breakpoint on line 75 of PasteBinClient and evaluate the contents of the resp variable.

    Based on the pastebin API documentation, you should get a message telling you exactly what's wrong with your request:

    Bad API request, invalid api_option
    Bad API request, invalid api_dev_key
    Bad API request, IP blocked
    ... etc
    

    EDIT: User commented with exact issue: invalid api_paste_format.

    In your program (line 31) you're passing in "None" as the format - have you tried "text", as suggested by the API docs?