API v2 with VBA

Attempting to push a record (item) to a board from an Excel DB using VBA. The script adds an item as intended from the try-it-yourself utility. (I built the script in the code and captured it from the function [strJSON] just to make sure it was identical.) The token (strToken) was taken from my account page, and was used in the utility as well. So, I am certain that there are no errors in the script, but just for clarity, here it is:

mutation { create_item( board_id: XXXXXXX, group_id: “topics”, item_name: “My Company”, column_values: “{“text8”:“Me”,“date4”:{“date”:“2019-11-10”}}”)}

I cannot get it to rpocess the added item using VBA. My code is:

Dim http As Object
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")

http.Open "POST", strURL, False
http.setRequestHeader "Content-Type", "application/json"
http.setRequestHeader "Authorization", strToken
http.Send strJSON

PushToMondayPM = http.responseText
strError = http.statusText
Set http = Nothing

The responseText is empty, and the statusText says “Bad Request”.

Also, FWIW, there is conflicting information if the APIv2 URL is api.monday.com/v2 or COMPANY.monday.com/v2.

Any help or sample code that you can provide is greatly appreciated. Thanks!


Hey @HydroCompDon!

I don’t have a lot of VBA experience so I’ll let the community handle this :slight_smile: However, I did notice something: you’ve got some strings-inside-strings in your column_values parameter. Can you ensure you’re escaping all strings and double-escaping nested strings? This will ensure your query is parsed correctly.

Here’s an example of a properly escaped string:

Set queryString = "mutation { create_item( board_id: XXXXXXX, group_id: \“topics\”, item_name: \“My Company\”, column_values: \“{\\\“text8\\\”:\\\“Me\\\”,\\\“date4\\\”:{\\\“date\\\”:\\\“2019-11-10\\\”}}\”)}"

Thanks for the reply. I tried to push your “escaped” string into the try-it-yourself utility and it failed (where my example worked). Is the “escaping” different when pushed through code as I have described?