title: POSTing Pastebin API to create a past in Python and get a correct reply, yet the pasted data is incorrect
body: <p>So I am attempting to code a program that POSTs towards Pastebin and creates a new paste. The posting, requesting, etc is all going fine - yet when I check the actual Paste, it is just a single word in the source code. I sent the POSTed data to <a href="https://httpbin.org/post" rel="nofollow noreferrer">https://httpbin.org/post</a> and all the data is fine, yet I get the wrong pasted data.</p>
  <p>Code:</p>
  <pre><code>#!/usr/bin/python3
  
  import requests
  import argparse
  import sys
  
  epilog = &quot;&quot;&quot;Usage: sourcepaste [ FILENAME ] [ LANGUAGE ] [ OPTIONS ]
  
            Example use(s):
                  sourcepaste testfile.py python 2 6M
                  sourcepaste source.cpp cpp
                  sourcepaste js.js javascript 1
                  &quot;&quot;&quot;
  
  parser = argparse.ArgumentParser(description='A CLI-based way to post on Pastebin',
                                   prog=&quot;sourcepaste&quot;,
                                   epilog=epilog)
  parser.add_argument('source',
                      help='the file of your source code')
  parser.add_argument('language',
                      help='the language of your source code | check langs.txt for all available languages')
  parser.add_argument('privacy', nargs='?',
                      help='how private you want your post | 0 = Public, 1 = Unlisted, 2 = Private | Default = 0')
  parser.add_argument('time', nargs='?',
                      help=&quot;&quot;&quot;when your post should expire | N(ever), 10M(inutes), 1H(our), 1D(ay),
                           1W(eek), 2W(eeks), 1M(onth), 6M(onths), 1Y(ear) | Default = 1W(eek)&quot;&quot;&quot;)
  
  parse_args = parser.parse_args()
  
  headers = {
      'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36',
      'Content-Type': 'application/x-www-form-urlencoded'
  }
  
  with open(parse_args.source, &quot;r&quot;) as source_code_read:
      source_code_content = source_code_read.read()
  
  if (len(sys.argv) - 1) == 2:
      data = f&quot;api_dev_key=&lt;my-dev-key&gt;&amp;api_paste_code={source_code_content}&amp;api_option=paste&amp;api_user_key=&lt;my-user-key&gt;&amp;api_paste_expire_date=1W&amp;api_paste_private=0&amp;api_paste_name={parse_args.source}@{parse_args.language}&amp;api_paste_format={parse_args.language}&quot;
  elif (len(sys.argv) - 1) == 3:
      data = f&quot;api_dev_key=&lt;my-dev-key&gt;&amp;api_paste_code={source_code_content}&amp;api_option=paste&amp;api_user_key=&lt;my-user-key&gt;&amp;api_paste_expire_date=1W&amp;api_paste_private={parse_args.privacy}&amp;api_paste_name={parse_args.source}@{parse_args.language}&amp;api_paste_format={parse_args.language}&quot;
  elif (len(sys.argv) - 1) == 4:
      data = f&quot;api_dev_key=&lt;my-dev-key&gt;&amp;api_paste_code={source_code_content}&amp;api_option=paste&amp;api_user_key=&lt;my-user-key&gt;&amp;api_paste_expire_date={parse_args.time}&amp;api_paste_private={parse_args.privacy}&amp;api_paste_name={parse_args.source}@{parse_args.language}&amp;api_paste_format={parse_args.language}&quot;
  
  pageget = requests.post(&quot;https://pastebin.com/api/api_post.php&quot;, headers=headers, data=data)
  
  print(pageget.content)
  </code></pre>
  <p>My shell inputs:</p>
  <pre><code>./sourcepaste test.py python 2 N
  </code></pre>
  <p>Example reply:</p>
  <pre><code>https://pastebin.com/IuHbDt
  </code></pre>
  <p>Content at link:</p>
  <p><code>{test_content}</code> - no other pieces of the code</p>
  <p>Would love some help on this; to me it's very strange how the POST data is correct, the reply is fine, yet the actual paste is incorrect.</p>
  <p>Thanks!</p>