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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:26:34+00:00 2026-06-12T08:26:34+00:00

I’m struggling to translate this command (that I can successfully run) curl -X POST

  • 0

I’m struggling to translate this command (that I can successfully run)

curl -X POST https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: multipart/related" \
-F "metadata=@metadata.txt;type=application/json;charset=UTF-8" \
-F "file=@upload.jpg;type=image/jpeg"

to a python script using pycurl:

import pycurl
url = 'https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart'

c = pycurl.Curl()
c.setopt(c.POST, 1)
c.setopt(c.USERAGENT, 'Curl')
c.setopt(c.VERBOSE, 1)
c.setopt(c.URL, url)
c.setopt(c.HTTPHEADER, [
    'Authorization: Bearer %s' % str(ACCESS_TOKEN),
    'Content-Type: multipart/related',
])

data = [
     ('metadata', (c.FORM_FILE, 'metadata.txt')),
     ('type', 'application/json'),
     ('charset', 'UTF-8'),
     ('file', (c.FORM_FILE, 'upload.jpg')),
     ('type', 'image/jpeg'),
]
c.setopt(c.HTTPPOST, data)
c.perform()
c.close()

but I always get this error when i run the script

* About to connect() to www.googleapis.com port 443 (#0)
*   Trying 74.125.132.95... * connected
* found 153 certificates in /etc/ssl/certs/ca-certificates.crt
*    server certificate verification OK
*    common name: *.googleapis.com (matched)
*    server certificate expiration date OK
*    server certificate activation date OK
*    certificate public key: RSA
*    certificate version: #3
*    subject: C=US,ST=California,L=Mountain View,O=Google Inc,CN=*.googleapis.com
*    start date: Thu, 27 Sep 2012 01:23:09 GMT
*    expire date: Fri, 07 Jun 2013 19:43:27 GMT
*    issuer: C=US,O=Google Inc,CN=Google Internet Authority
*    compression: NULL
*    cipher: ARCFOUR-128
*    MAC: SHA1
> POST /upload/drive/v2/files?uploadType=multipart HTTP/1.1
User-Agent: Curl
Host: www.googleapis.com
Accept: */*
Authorization: Bearer ACCESS_TOKEN
Content-Length: 43373
Expect: 100-continue
Content-Type: multipart/related; boundary=----------------------------b91f88a180be

* Done waiting for 100-continue
< HTTP/1.1 400 Bad Request
< Server: HTTP Upload Server Built on Sep 26 2012 16:51:11 (1348703471)
< Content-Type: application/json
< Date: Fri, 05 Oct 2012 15:20:26 GMT
< Pragma: no-cache
< Expires: Fri, 01 Jan 1990 00:00:00 GMT
< Cache-Control: no-cache, no-store, must-revalidate
< Content-Length: 171
* HTTP error before end of send, stop sending
< 
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "parseError",
    "message": "Parse Error"
   }
  ],
  "code": 400,
  "message": "Parse Error"
 }
}
* Closing connection #0

Do you know the right translation?

I’ve removed the access token of the code examples for security reasons

  • 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-12T08:26:37+00:00Added an answer on June 12, 2026 at 8:26 am

    just found the solution

    data values must be this way:

    data = [
        ('metadata', (
            c.FORM_FILE, 'metadata.txt', 
            c.FORM_CONTENTTYPE, 'application/json')),
        ('file', (
            c.FORM_FILE, 'upload.jpg', 
            c.FORM_CONTENTTYPE, 'image/jpeg'))
    ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.