Skip to main content

My challenge is very similar to this thread from @vprado: Working with API v2 and VBA - Parsing Mutation. I can query and create items using VBA , but what I’m attempting is to use variables to create subitems with column values populated. I was hoping someone would share an example of VBA code which uses variables to create subitem values, similar to how we can do it in Python here: https://support.monday.com/hc/en-us/articles/360013483119#


In VBA, I’ve tried many different types of formatting, escaping "", double escaping the nested variables’ values \\" based on this thread: C# Create_Item with Column_Values leads to (500) Internal Server Error - #4 by Will


It works fine in Python, where mutate is the final string including the variables which gets passed to the post request as json:


query_msubitem = 'mutation ($StockCode: String!, $columnVals: JSON!) { create_subitem (parent_item_id: 2416200000, item_name:$StockCode, column_values:$columnVals) { id board { id } } }'
vars = {
'StockCode' : '300.TEST1',
'columnVals' : json.dumps({
'text' : 'Things'})
}
mutate = {'query' : query_msubitem, 'variables' : vars}

resp = requests.post(url=apiUrl, json=mutate, headers=headers)

In the watch window, mutate resolves to:


{'query': 'mutation ($StockCode: String!, $columnVals: JSON!) { create_subitem (parent_item_id: 2416200000, item_name:$StockCode, column_values:$columnVals) { id board { id } } }', 'variables': {'StockCode': '300.TEST1', 'columnVals': '{"text": "Things"}'}}


I’ve managed to get VBA producing a perfectly identical string, but when I send that string to Monday, it returns {} and a 500 Internal Server Error.


Dim monday As New WinHttpRequest
With monday
.Open "POST", apiURL, False
.SetRequestHeader "Content-Type", "application/json"
.SetRequestHeader "Accept", "application/json"
.SetRequestHeader "Authorization", apiKey
.Send mutate
response = .ResponseText
status = .status & " | " & .StatusText
End With

This VBA works to create a subitem:


query_msub = " { ""query"" : ""mutation{ create_subitem (parent_item_id: " & ItemID & ", item_name: \\""300.TEST2\\"") { id board { id } } }"" }"


But I am stuck on how to create a subitem and construct and pass the column values along with it.

Hello @jsararas!


We have replied to your email 🙂


Talk to you over there!


Cheers,

Matias


Reply