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

  • Home
  • SEARCH
  • 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 3348308
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:31:37+00:00 2026-05-18T01:31:37+00:00

I am attempting to send POST data using urllib, but the problem is normally

  • 0

I am attempting to send POST data using urllib, but the problem is normally you urlencode your dictionary of fields and then you send that along with your request. But some of my fields that I have to send to the server are named the exact same name, so using a dictionary I end up deleting a lot of my data out of the dictionary because you can’t have two keys with the same name and different data.

I have my request data in a string format in the correct syntax(eg. var=value&var=value2&…) and I try to send that along with my urllib request, but I get a bad request every time. Is there any other way to urlencode the data before sending so I don’t get a 400?

  • 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-18T01:31:38+00:00Added an answer on May 18, 2026 at 1:31 am

    urllib.urlencode() can take a list of tuples, allowing you to specify multiple values for a parameter:

    >>> urlencode([("var", "value"), ("var", "value2")])
    'var=value&var=value2'
    

    Or use a map with lists as values:

    >>> p = {"var": ["value", "value2"], "var2": ["yetanothervalue"]}
    >>> urlencode([(k, v) for k, vs in p.items() for v in vs])
    'var=value&var=value2&var2=yetanothervalue'
    

    You could even allow lists or strings as values, although it becomes less concise:

    >>> p = {"var": ["value", "value2"], "var2": "yetanothervalue"}
    >>> urlencode([(k, v) for k, vs in p.items()
    ...     for v in isinstance(vs, list) and vs or [vs]])
    'var=value&var=value2&var2=yetanothervalue'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to send a dictionary from jQuery to Django using a getJSON call:
I'm working with activemq-cpp and I am attempting to send binary data using BytesMessage.
I am attempting to send an email using VB.NET. There are two requirements: The
I'm attempting to send HTML formatted emails using C# 3 via Outlook.MailItem Outlook.MailItem objMail
I am attempting to send html data in a question form from my php
I'm attempting to send a piece of data through jQuery .ajax() to a PHP
Hey guys, I am attempting to post and image-type post to Tumblr using someone's
I am attempting to send data back to my objective c program from javascript.
I am attempting to send Base64 image data via ajax to Server. Sometimes all
I'm attempting to use the rest-client gem to post something, but for some reason,

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.