Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence rest api, create attachment with python. Internal server error (500)

Oskar Granlund
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 13, 2018

Hi, I'm developing a script to export documents from Doors to Confluence. Currently I want to append the generated pdf as an attachment on a confluence page.


I developed the plugin on a linux machine using python 3 and the requests library. On my linux machine everything worked fine I could create new attachments just as I wanted.

However, doors is a windows application and I cloned the code to my windows machine installed the requests library on my python 3. At first it looked good, I could update existing attachments create new pages but when I tried to create a new attachment I received the error "500 Internal server error, message: java.lang.IllegalArgumentException: File name must not be null"

Now I'm clueless how to proceed..
I went into the source code of the requests library to print out what's actually is sent to the rest api


Linux side(Working request):

rest url: http://baseurl/rest/api/content/23003339/child/attachment/

Data: None
Json: None

**Kwargs: {'headers': {'X-Atlassian-Token': 'nocheck'}, 'files': {'file': ('/home/user/workspace/export/ref_data/xxx.pdf',
<_io.BufferedReader name='/home/user/workspace/export/ref_data/xxx.pdf'>,
'application/pdf')}, 'verify': False, 'auth': ('admin', 'password')}

 

Windows side(Not working)

rest url: http://baseurl/rest/api/content/23003349/child/attachment/

Data: None
Json: None

**Kwargs:  'verify': False, 'auth': ('admin', 'password')} , 'files': {'file': ('C:\\home\\user\\workspace\\export\\ref_data\\xxx.pdf',
<_io.BufferedReader name='C:\\home\\user\\workspace\\export\\ref_data\\xxx.pdf'>,
'application\\pdf')}, {'headers': {'X-Atlassian-Token': 'nocheck'}}

 

 

This is what is sent to the rest API, the order of the kwargs dictionary seems to differ a little bit but that should not be a problem? The other thing is that the paths looks different.

I run the exact same code on linux and windows and yet it's not working I'm grateful for any tips helping me forward.

//Oskar

1 answer

0 votes
Thomas Deiler
Community Champion
July 13, 2018

Dear @Oskar Granlund,

have you tried to create a page (with no attachments) from Win/Python? Just to exclude that this is a Win-Lib problem.

So long

Thomas

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events