How do I upload an image to ETM via a POST request using REST API?
I have been attempting to upload a .png image to ETM using a POST request via REST API. I am returning a 201, as well as a slugID, which tells me that it is working. The problem is that when I try to then view the image, using what is assumed to be the correct URL (the one returned in the response), there is nothing there. I have followed the footnote 6 in the ETM REST API documentation, but apparently I'm still doing something wrong. Possibly using the wrong URI to POST? I'm not really sure and can't seem to find any existing solutions out there, though I have found similar type issues/questions.
Thank you.
ETM version 7.0.2
|
One answer
Figured something out. My solution using python for posting a test script with multiple images:
........
for idx, name in enumerate(dict['names']):
with open(newpath + '/' + name, mode='rb') as file:
name_img = name
files = {'image': (name_img, file, 'multipart/mixed',{Expires': '0'})}
url = <resourceurl>
response = session.post(url, file=files)
........
Look at ETM API documentation for <resourceurl> definition and example. The resource type is "attachment."
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.