- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
08-23-2023 05:02 AM
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}))
08-23-2023 12:02 PM
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?
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!