Hey Community,
I’m attempting to hit the GQL endpoint from serverless function. When requested I get the response:
{
"response": {
"statObjs": {
"message": "Request failed with status code 400",
"name": "Error",
"stack": "Error: Request failed with status code 400\n at createError (/opt/nodejs/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/opt/nodejs/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/opt/nodejs/node_modules/axios/lib/adapters/http.js:236:11)\n at IncomingMessage.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1241:12)\n at processTicksAndRejections (internal/process/task_queues.js:84:21)",
"config": {
"url": "https://api.hubapi.com/collector/graphql?hapikey=XXXXXXXXXXXXXXXXX",
"method": "post",
"data": "{\"header\":{\"Content-Type\":\"application/json\",\"Accept\":\"application/json, text/plain, */*\"},\"body\":\"\\\"{\\\\n \\\\\\\"operationName\\\\\\\": \\\\\\\"myquery\\\\\\\",\\\\n \\\\\\\"query\\\\\\\": \\\\\\\"query myquery($contactid: String!,$id: String!,$reporttype: String!) { CRM {contact(uniqueIdentifier: $id, uniqueIdentifierValue:$contactid) { name associations { p_repoted_stat_collection__reported_stat_to_contact(limit: 200, filter: {recordtypename__eq: $reporttype}) {total items {report_week}} } }}}\\\\\\\",\\\\n \\\\\\\"variables\\\\\\\": {\\\\\\\"contactid\\\\\\\": \\\\\\\"1398551\\\\\\\", \\\\\\\"id\\\\\\\": \\\\\\\"id\\\\\\\", \\\\\\\"reporttype\\\\\\\": \\\\\\\"weekly\\\\\\\"}\\\\n }\\\"\"}",
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json;charset=utf-8",
"User-Agent": "axios/0.19.2",
"Content-Length": 631
},
"transformRequest": [
null
],
"transformResponse": [
null
],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1
}
}
}
}
The Integrations Call Log:
{
"status": "error",
"message": "Invalid input JSON on line 1, column 631: Cannot build GraphQLQuery, some of required attributes are not set [query]",
"correlationId": "XXXXXXXXXX"
}
The query:
{
"operationName": "myquery",
"query": "query myquery($contactid: String!,$id: String!,$reporttype: String!) { CRM {contact(uniqueIdentifier: $id, uniqueIdentifierValue:$contactid) { name associations { p_repoted_stat_collection__reported_stat_to_contact(limit: 200, filter: {recordtypename__eq: $reporttype}) {total items {report_week}} } }}}",
"variables": {"contactid": "1398551", "id": "id", "reporttype": "weekly"}
}
When using this query with postman I do get the expected results.
I can’t quite figure out whats causing the query not to be set?