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 8910279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:38:59+00:00 2026-06-15T03:38:59+00:00

The API to which I need to make request require parameters in specified order.

  • 0

The API to which I need to make request require parameters in specified order. At first I had used requests lib

payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.get("http://httpbin.org/get", params=payload)

Like is says in documents. requests does not take parameters explicit

r = requests.get("http://httpbin.org/get", param1=payload1, param2=payload2)

After I had tryed urllib3 directly, but it returns me an error as above. From error:

def request_encode_body(self, method, url, fields=None, headers=None,

How to set http request parameters in specified order in Python, any libs.

  • 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-06-15T03:39:00+00:00Added an answer on June 15, 2026 at 3:39 am

    Use a sequence of two-value tuples instead:

    payload = (('key1', 'value1'), ('key2', 'value2'))
    r = requests.get("http://httpbin.org/get", params=payload)
    

    The reason requests doesn’t retain ordering when using a dictionary is because python dictionaries do not have ordering. A tuple or a list, on the other hand, does, so the ordering can be retained.

    Demo:

    >>> payload = (('key1', 'value1'), ('key2', 'value2'), ('key3', 'value3'))
    >>> r = requests.get("http://httpbin.org/get", params=payload)
    >>> print r.json
    {u'url': u'http://httpbin.org/get?key1=value1&key2=value2&key3=value3', u'headers': {u'Content-Length': u'', u'Accept-Encoding': u'gzip, deflate, compress', u'Connection': u'keep-alive', u'Accept': u'*/*', u'User-Agent': u'python-requests/0.14.1 CPython/2.7.3 Darwin/11.4.2', u'Host': u'httpbin.org', u'Content-Type': u''}, u'args': {u'key3': u'value3', u'key2': u'value2', u'key1': u'value1'}, u'origin': u'109.247.40.35'}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to make a request to an API which returns json formatted data.
I'm using the Foursquare API and I need to make a request to their
I'm trying to make a POST request using HTTParty, in which I need the
I have to deal with an API which need to be provided a DataSource
I need to connect to a secure API which requires a certificate be attached
I'm building a service which will need to access a certain Big Corp API
I need to start a project that will be json-API-centric, which means that most
I am using an API which has a limit on requests. The API response
So I need to make a a cross domain request where the response is
I make a request to an external API using GET method. For some reasons,

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.