新しいBoxサポートサイトへようこそ。 変更点の詳細はこちらをご確認ください .

File Upload Error 500, unable to upload

新規投稿

コメント

2件のコメント

  • Murtza

     Can you please share the request your code generates including the request headers and body? Please remove your credentials before posting.

    0
    コメントアクション パーマリンク
  • Tapasvi

    Hi Murtza,

     

    Thank you for the response. Here's the piece of my code, I'm not sure what you're looking for. But I hope this helps, let me know. Thanks.

     

     

    params = (
    ('response_type', 'code'),
    ('client_id', 'dafdsffdd3***phone number removed for privacy***'),
    ('state', 'OPEPEPEPEPEPE'),
    )

    redirect =False
    response = requests.get('https://account.box.com/api/oauth2/authorize', params=params ,allow_redirects = redirect)
    driver = webdriver.Chrome("C:/CCF/Drivers/chromedriver.exe")
    ......
    .....
    ...... (some piece of code)
    ...............
    ...........
    data = [
    ('grant_type', 'authorization_code'),
    ('code', unique_code),
    ('client_id', 'fsgsdfgefdsafds2332232'),
    ('client_secret', 'ABCDEFdfgdgd525353455'),
    ]

    response1 = requests.post('https://api.box.com/oauth2/token', data = data)
    data = json.loads(response1.text)
    box_access_token = (data ['access_token' ])
    box_refresh_token = (data ['refresh_token' ])
    auth_value = 'Bearer '+ box_access_token
    #print(auth_value)

    headers = { 'Authorization': auth_value ,'Content-Type': 'application/x-www-form-urlencoded','Content-Type': 'multipart/form-data',}
     
    def upload_file (upload_files😞
    DestFolder_Parent = input ("Please enter the Exact Name of folder's OWNER: ")
    Dest_folder = input ("Please enter the Exact Name of the FOLDER: ")
    params = (('query', Dest_folder),)
    response = requests.get('https://api.box.com/2.0/search', headers=headers, params=params)
    data = json.loads(response.text)
    for value in data ['entries']:
    if (value['owned_by']['name'] in [DestFolder_Parent] and
    value['name'] in [Dest_folder]):
    up_fid = value['id']
    print(up_fid)
     
    fp='000 Test Folder'
    save_path = pathlib.Path('C:/Users/u78633/Downloads/')
    pathname = os.path.join(save_path, fp)
     

    for i in upload_files:
    os.path.join(pathname,i)
    completeName = os.path.join(pathname,i)
    print(completeName)
    files = {
    'attributes': (None, '{"name":"%s", "parent":{"id":"%s"}}'% (i, up_fid)),
    'file': (i, open(completeName, 'rb')),
    }
    print(files)
    for attempt in range(10😞
    time.sleep(1)
    try:
    response = requests.post(ufile_url, headers= headers,files=files, )
    print(response.status_code)
    except requests.HTTPError as exc2:
    if exc2.response.status_code != 500:
    raise exc2
    return
     
    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。