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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:53:57+00:00 2026-06-17T18:53:57+00:00

I am trying to write a Python script to POST a multipart form to

  • 0

I am trying to write a Python script to POST a multipart form to a site that requires authentication through CAS.

There are two approaches that both solve part of the problem:

  1. The Python requests library works well for submitting multipart forms.

  2. There is caslib, with a login function. It returns an OpenerDirector that can presumably be used for further requests.

Unfortunately, I can’t figure out how to get a complete solution out what I have so far.
There are just some ideas from a couple hours of research; I am open to just about any solution that works.

Thanks for the help.

  • 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-17T18:53:58+00:00Added an answer on June 17, 2026 at 6:53 pm

    You could use poster to prepare multipart/form-data. Try to pass poster’s opener to the caslib and use caslib’s opener to make requests (not tested):

    import urllib2
    
    import caslib
    import poster.encode
    import poster.streaminghttp
    
    opener = poster.streaminghttp.register_openers()
    r, opener = caslib.login_to_cas_service(login_url, username, password,
                                            opener=opener)    
    params = {'file': open("test.txt", "rb"), 'name': 'upload test'}
    datagen, headers = poster.encode.multipart_encode(params)
    response = opener.open(urllib2.Request(upload_url, datagen, headers))
    print response.read()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a Python script that uses a particular external application belonging
I am trying to write a python script that takes record data like this
I am trying to write a python script that will change my cwd to
I am trying to write a python script that I could easily export to
I'm trying to write a python script that does the following from within a
I am trying to write a Python script that will access and modify the
I'm trying to write a simple Python script that inserts .odt documents into an
I am trying to write a python script that will SSH to a server
I’m trying to write a python script that sends a query to TweetSentiments.com API.
I'm trying to write a python script that modifies the contents of <script> tag

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.