Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7442579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:11:46+00:00 2026-05-29T11:11:46+00:00

I am trying to send POST data from a python script to a url.

  • 0

I am trying to send POST data from a python script to a url. Here is the code:

def createperson(self,name=None):
        SERVER_BASE_ADDR = 'http://localhost:8000/'
        postdata = urllib.urlencode({'name':name})
        req = urllib2.Request(SERVER_BASE_ADDR + 'people/add')
        fd = urllib2.urlopen(req,postdata)
        return name

But this returns

HTTPError: HTTP Error 500: INTERNAL SERVER ERROR

Adding a person on the url is fine. Any ideas?

EDIT

The server side uses django decorators to handle POST and GET.

@require_http_methods(["GET", "POST"])
def add(request):
       if request.method == "POST":
           #do stuff with post data

Isn’t the above python code the same as submitting a form on a html template? If its the same then shouldn’t the handlers handle it the same way?

Thank you

Solved by using:

c = urllib2.build_opener()
postdata = urllib.urlencode({'name':name})
r = c.open(url,postdata)

A different approach but does the job. Thank you for all your answers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:11:47+00:00Added an answer on May 29, 2026 at 11:11 am

    The HTTP 500 error means that the problem doesn’t occur on the client-side python script, but on the server side.

    Check your server side code, maybe it reads data only from GET, not POST.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to find a way to send a POST HTTPS request from Python to
I am trying to send the POST data from java to a PHP page.
I am trying to output POST-data that I send from an android phone, however
I'm trying to send a lot of data from a form using the $.post
I am trying to send data from a form to a database. Here is
I'm trying to send data from a form to an external script prior to
I'm trying to send a POST request from an external Ruby script to a
I'm tying to send POST data from one site to another (both sites have
I'm trying to send post data between pages with Post. Not a form -
While trying to send a POST request via xmlhttp.open(POST, url, true) (javascript) to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.