0

I've successfully downloaded the file from BIM360 using Postman for testing. Now I'm trying to implement this request in Ironpython urllib2 (cause urllib2 is my only choice for this task in the standard library to my knowledge) but I'm getting the error:

Exception : System.IO.IOException: Authentication failed because the remote party has closed the transport stream.

Code:

import urllib2
import shutil 


url = 'https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/xxx.txt'

head = {
'User-Agent': 'user-agent',
'Authorization':'Bearer xxx',
'x-user-id':'xxx'}

dst = 'C:\Users\xxx\OneDrive - MyCompany\Desktop\sptext.txt'

req = urllib2.Request(url, headers=head)

with urllib2.urlopen(req) as response:
    shutil.copyfileobj(response, dst)

Any help is appreciated.

Marcus
  • 21
  • 4

1 Answers1

0

A quick search on Stack Overflow shows that this could be related to the urllib2 library itself, and its default settings for security protocols: Authentication failed because the remote party has closed the transport stream exception when getting a response from webservice.

Btw. while Forge does not provide an official SDK for Python (at least not yet), I started putting together an unofficial SDK here: https://github.com/petrbroz/forge-sdk-python. It uses requests under the hood, and it already supports some of the basic Forge APIs. Feel free to use it as an inspiration for your own code.

Petr Broz
  • 8,891
  • 2
  • 15
  • 24
  • I ended up using System.Net.WebClient() for my request. Thanks for the Python SDK work I definitely look into it though! – Marcus Feb 01 '22 at 23:47