Skip to main content

Creating an item and upload a file

  • October 14, 2021
  • 9 replies
  • 3144 views

Hi, I need help I’m sending an http request from Power Apps, so every time a new email comes in on outlook I send the email data to monday.com including the email attachments if there’s any.

Here is my request’s body:

{
  "query": "mutation { create_item (board_id: 1622487816, group_id: \\"emailed_items\\", item_name: \\"@{triggerOutputs()?['body/subject']}\\", column_values: {attachment:@{triggerOutputs()?['body/attachments']} }) { id } } "
}

This is the Error I am getting from Monday:

{
  "errors": [
    {
      "message": "Parse error on \\"@odata.type\\" (STRING) at [1, 130]",
      "locations": [
        {
          "line": 1,
          "column": 130
        }
      ]
    }
  ],
  "account_id": 9415663
}

Please assist and thanks in advance.

This topic has been closed for replies.

9 replies

AlexSavchuk
Forum|alt.badge.img
  • monday.com Team Member
  • October 14, 2021

Hey again, @mxolisi! 👋

I’d love to help with this.

There are a couple of things that I think might be at play here:

  1. It is not possible to create an item AND upload a file in a single mutation call. You’d have to use create_item first, and then the file upload mutations (add_file_to_update,add_file_to_column);
  2. You will also need to send the file’s byte-stream when uploading the file to monday.com. As such, you will most likely need to upload the file from local storage, so I don’t think Power Automate will do the trick here.

I recommend taking a look at our API docs for Files, as it has some examples of how this works in JavaScript, and how you could set this up.

I hope this helps, although I understand it isn’t quite the answer you were looking forwardd to.

-Alex


  • Author
  • Participating Frequently
  • October 14, 2021

Hi @AlexSavchuk , Thanks for your help, and yes Sir I do understand, maybe I should just write a python script to do all these steps for me.


  • Author
  • Participating Frequently
  • October 14, 2021

Hi @AlexSavchuk , I’m just curious, so there’s no way I can send the file as a base64 to monday?


AlexSavchuk
Forum|alt.badge.img
  • monday.com Team Member
  • October 14, 2021

@mxolisi

Perhaps the mon-cli client for Python might be helpful, in that case? It already has most of the API functions you’d need to implement something similar.

In terms of uploading files, you’ll need to use binary data, so perhaps base64 could work too.

-Alex


  • Author
  • Participating Frequently
  • October 14, 2021

Awesome, thanks Alex.


AlexSavchuk
Forum|alt.badge.img
  • monday.com Team Member
  • October 14, 2021

Sure thing! Just realized I forgot to add the mon-cli link, so here you go:

Moncli Version 1.2 Release

Pass some praise to Andrew and Trix Solutions, they deserve it 🙂

-Alex


andrew.shatz
  • Participating Frequently
  • October 14, 2021

Hello @mxolisi and @AlexSavchuk

Firstly, thank you @AlexSavchuk so much for the endorsement! We are truly thankful for the support, for we have put a great deal of time into this SDK so that you don’t have to. 😉👍

As far as uploading files from base64, Moncli does not support that natively. However if you are able to write the file locally to disc, you can use that file path to upload the file after the item has been created. Here is an example below of how the file upload can be done:

from moncli import client
client.api_key = 'insert_api_key'

board_name = 'insert_board_name'
file_column_title = 'insert_file_column_title' # You can use ID, but it is easier this way.
file_path = 'insert_full_file_path'

board = client.get_board(name=board_name)
# This will return your newly created item with all of your column values in one request.
item = board.add_item('item_name', get_column_values=True) 
file_value = item.column_values[file_column_title]
asset = item.add_file(file_value, file_path)

I would be happy to work with you @mxolisi further should you need any assistance.

All the best and happy coding!

Andrew


  • Author
  • Participating Frequently
  • October 15, 2021

Hi @andrew.shatz , thanks this is cool and makes it even easier for me, I appreciate it Sir.


  • October 22, 2021

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.