Uploading report via demisto api post request

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Uploading report via demisto api post request

L1 Bithead

Hello everyone,

 

I am trying to upload json file to create report. Despite I tried tons of way I couldn't send the body properly. demisto-api-post request need multipart/form-data content type. Is there any way to send raw json properly?

 

Here is my code;

content = demisto.args().get('page_content')
page_number = demisto.args().get('page_num')

body= ""


json_template = safe_load_json(execute_command('demisto-api-get', {'uri':"/reports/bc874b4f-48aa-4a21-8f52-0c18450ce541"}))
layout_contents = json_template['response']['dashboard']['layout']

for widget_content in layout_contents:
    if page_number == widget_content['widget']['name']:
        widget_content['widget']['params']['text'] = content
        
body = (json.dumps(json_template['response'])).replace('"','\\"')

return_results(execute_command('demisto-api-post', {'uri':"/reports/upload",'files':body}))
2 REPLIES 2

L3 Networker

Hi,

 

Just to summarize the use case, you read a report from the GET request, add a custom widget, and attempt to re-upload. Is this correct? 

yes,correct

  • 827 Views
  • 2 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!