Skip to main content

I’m trying to get data from a pipe using Google Apps Script and keep getting the error:

Info	{"errors":"{"message":"Unexpected end of document","locations":"]}]}

I don’t think the problem is with the general script’s structure, since it works when I run another query.

Also, I’m new to GRAPHQL - this is the first time I use it, for instance - so that’s another reason why I believe the problem might be in the query.

A piece of the script I used to try is:

  const query = `{
allCards(pipe_id:${pipe_id}){
edges{
node {
title
current_phase {
name
}
createdBy {
name
}
createdAt
fields {
value
name
}
}
}
}`;
const graphql = JSON.stringify({
query: query,
variables: null,
});
const params = {
method: "GET",
payload: graphql,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${TOKEN}`,
},
};
var response = UrlFetchApp.fetch(url, params);

pipe_id and TOKEN and variables defined previously in the script.

 

Also, something that I didn’t set yet are the filters: I’d like to take data only from the cards in specific phases for which I have the names (example: phase_1, phase_2...).

 

My final goal is to take the data object and transform it to build a table with columns bTitle, Current Phase Name, Creator’s Name, Created At, Specific Field Name] and where each row will represent a card’s info. 

Solution: there was one } missing in the query variable.


Reply