Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes



One answer

Permanent link

 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."

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,027

Question asked: Jul 07 '22, 3:33 p.m.

Question was seen: 1,357 times

Last updated: Aug 30 '22, 6:56 p.m.

Confirmation Cancel Confirm