Getting error when trying to mutate or execute, using React App

Hi,

I am trying to

  1. Open an item using monday.execute(‘openItemCard’, { itemId: props.id })
    I get “Uncaught TypeError: Cannot read property ‘board_id’ of undefined” error

  2. Change Status of an item using following code
    const valueString = {'label': ${dStatusLabel}}
    monday.api(mutation ($boardId: Int!, $itemId: Int, $valueString: JSON!) {change_column_value (board_id: $boardId, item_id: $itemId, column_id: "status", value: $valueString) {id}}, {variables:{boardId: this.state.boardData.boards[0].id, itemId: parseInt(itemId), valueString: valueString}}).

I get “Error: There was an error in response from monday.com graphql API” and a 500 network response.

I am totally stuck on these. Can someone please help me out?

Hey there @ksholla20 :wave:

A very warm welcome to the community and I hope you enjoy your stay. :slight_smile: Let’s try and tackle those points together!

It seems like in the 1st request you are trying to execute, you are missing the Board ID and the platform is not able to pull in the appropriate data for you. I am basing this on this part of the error:

Uncaught TypeError: Cannot read property ‘board_id’ of undefined

For the 2nd point, in my personal experience and for many users within the community, a 500 server error is usually caused by the request you are trying to send not being formatted in the way that the API can recognize. Can you please make sure that:

  1. Your query is sent as a JSON body and a POST request?
  2. The column values you are trying to send are JSON-escaped correctly?

Those are the usual culprits for the 500 error to come up for our users. Do you think those could apply to your case as well?

-Alex

@AlexSavchuk Thanks a lot for quick response.

For first one: The board_id missing is coming somewhere from inside the sdk library. I am not sure How to provide that information. Attaching the screen shot of error line

For 2nd one, I printed out column value and what I have is “{“label”: “Done”}”. Is there any React sample code to change the column value. I tried the same query on the graphql testbench provided and it works fine there. Hence, like you, I too suspect the react implementation by me

Some experiments for 2nd error:
I tried with example in this example app

For following data: "{"label": "Working on it"}", I get following error message somewhere deep in sdk
"This status label doesn't exist, possible statuses are: {0: Working on it, 1: Done, 2: Stuck, 7: Waiting for review}"

I changed it to {"label": "Working on it"}, i.e. removing outer quotes in the string, I get 500 error

Update on First one:
The error was in Local setup on ngrocks only. This was not seen in the build version. Hence we can treat this as closed.
The second one still persists though

@ksholla20

Thank you for getting back to me on this! I am really glad you were able to troubleshoot the first error on your own and get a result that works for you, that’s awesome.

As for the second error you are experiencing, could you please try parsing this as the column_values parameter in your mutation for the status column?

“{“label”: {“Done”}}”)

I still believe the main reason you are not able to send the values properly is the JSON formatting in your case. Do you think that could be the root cause too?

-Alex

@AlexSavchuk That worked. Thanks

1 Like