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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:03:41+00:00 2026-05-28T04:03:41+00:00

I am implementing a client library for a private HTTP-API using python requests .

  • 0

I am implementing a client library for a private HTTP-API using python requests. The API(which I don’t control) expects the parameters to be in a certain order, but python-requests doesn’t honor a sorted dict as parameter.

This is what i tried:

import requests
from django.utils.datastructures import SortedDict

params = SortedDict()
params['s'] = 'value1'
params['f'] = 'value2'

requests.get('https://example.org/private_api', params=params)
#performs request as https://example.org/private_api?f=value1&s=value2 

This is what I am trying to avoid:

requests.get('https://example.org?{0}'.format(urlencode(params)))
  • 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-28T04:03:42+00:00Added an answer on May 28, 2026 at 4:03 am

    Currently requests doesn’t allow to do this as you wish. This is of course shortcoming that will be fixed. However as params parameter can take not only dictionary but bytes as well you should be able to do something in between:

    from collections import OrderedDict
    from urllib import urlencode
    import requests
    
    params = OrderedDict([('first', 1), ('second', 2), ('third', 3)])
    requests.get('https://example.org/private_api', params=urlencode(params))
    

    This doesn’t work as I see due to bug in line 85 of models.py: self.params = dict(params or [].
    I raised this problem in issue Wrong handling of params given as bytes object

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

Sidebar

Related Questions

I am a newbie to Selenium and is implementing selenium-rc with Python client library.
I'm implementing client web service from .wsdl in C++ using gSOAP library. And i
I'm currently implementing a client application that POST's a file over HTTP and have
implementing publishActivity in PHP using the REST API using this code: $activity = array(
I am implementing a memcached client library. I want it to support several servers
BOSH (Bidirectional-streams Over Synchronous HTTP) is a sneaky way of implementing 2-way client-server communication
I'm trying to write a client app using monotorrent library with asp.net. there is
Do you recommend any good library or examples online for implementing an HTTPS client
I am implementing a custo crypto library using the Diffie-Hellman protocol (yes, i know
I have successfully built a thin client/server using Qt's Tcp Sockets API. I know

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.