Sending via Postman to create_item

{
    "query":"{mutation(myItemName: String){ create_item (board_id:2364371628, group_id:XXXXXX, item_name:\"New Leads\", column_values: $variables) { id } }",
    "variables": {"email":"test2@test2.com","firstName":"test2", "lastName":"test2", "companyName":"test2", "phoneNumber":"1234567890", "message": "here is a sample message"}
}

I’m trying to pull lead data from Marketo and send it into Monday.com via a webhook but can’t figure out how to write the correct query? I’ve added my key to headers so I know it is working. “New Leads” is the group Name but not sure how to get the Group ID. What else am I missing and how do I fix the query? The error I am getting is:

{
    "errors": [
        {
            "message": "Unexpected end of document",
            "locations": []
        }
    ],
    "account_id": 6562763
}
1 Like

Had to figure this out on my own as unfortunately the Monday.com & Marketo support teams were not so helpful. Please do better. I will explain my solution here so if other people are having the same problem they’ll have a starting point.

The main blocking issue was the fact that Marketo’s Webhook does not send as JSON even if their support tells you otherwise. This forced me to forego using a Marketo Webhook altogether and do everything on-page with JavaScript.

The tricky part was getting the form data to populate in the URL string on the confirmation page where the script for parsing the form fields into parsedVariables from the URL string was executed and sent via a fetch request. I found this workaround article that helped me get the job done: Appending form fields to the Thank You URL - Marketing Nation There is no easy way to do this out-of-the-box with Marketo.

The other blocking issue was formatting of the query to add variables in through string interpolation using back-ticks and template literals.

I fixed this by sending the query using string concatenation like so:


{
    'query' : 'mutation ($boardId: Int!, $group_id: String!, $item_name: String!, $columnVals: JSON!) {create_item (board_id: $boardId, group_id: $group_id, item_name: $item_name, column_values: $columnVals) {id}}',
    'variables': {
     'boardId': 9999999999,
     'group_id': "topics",
     'item_name': parsedCompany,
     'columnVals': "{\"phone\":\"" + parsedPhone + "\",\"text\":\"" + parsedFirst +"\", \"text4\":\"" + parsedLast + "\", \"long_text\":\"" + parsedMessage +"\", \"status4\":\"Website Form\",\"email\":{\"text\":\"" + parsedEmail + "\",\"email\":\"" + parsedEmail + "\"}}"
 }
  }

The parsedValues were instantiated from the form fields taken from the url. Some things to note in the code above

 'item_name': parsedCompany 

no quotes needed on parsedCompany because the value of parsedCompany is already a string. And all the escaped fields that had variables, needed to be added via string concatenation. Another strange behavior of Monday is when sending the email over you will notice the fields need to be sent like this:

"email\":{\"text\":\"" + parsedEmail + "\",\"email\":\"" + parsedEmail + "\"}

Otherwise you will get an error for the email.

Finally, if you’re trying to figure out what Marketo uses for CompanyNotes as it’s not just CompanyNotes or Notes as one would expect but it is actually MktoCompanyNotes so when you parse fields into the URL you need the right form field names.

MktoForms2.whenReady(function(mktoForm){ const appendFieldsToTYQuery = [ 
{ mktoField: "Email" }, 
{ mktoField: "Phone" }, 
{ mktoField: "FirstName" }, 
{ mktoField: "LastName" }, 
{ mktoField: "Company" }, 
{ mktoField: "MktoCompanyNotes", } ];

Hope this helps!

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