Skip to main content

Rating column from PHP to API Monday : Can't reach to create an item with value into rating column

  • August 6, 2021
  • 13 replies
  • 1265 views

  • Participating Frequently

While creating a Monday API to connect our server to Monday board,
I want to create an item with values for each colums.
Problem : it works for every colum except for the rating one. I 've tried many syntax but no one works.
The official doc at https://api.developer.monday.com/docs/rating doesn’t help.
Does anybody know how to do it ?
Here is the code :

$column_values = [
    'name' => 'xxxxxxxxxx',
    'person' => '20985745',
    'status' => '14',
//    'classement' => '5',
//    'classement' => '5/5',
//    'classement' => "{\\"rating\\":1}",
//    'classement' => "{\\"rating\\":1\\"}",
//    'classement' => "{rating:1}",
//    'classement' => rating:1',
//    'classement' => {'rating:1'},
//    'classement' => "{\\"rating:1\\"}",
//    'classement' => 'rating 1',
    'classement' => 'rating\\:1',
    'date' => '2021-09-01 16:30:00',
    'texte' => 'Bonjour',
    'statut_1' => '1',
    'personnes' => '20791487',
    'lien_internet' => 'http://google.fr salut' 
 ];
This topic has been closed for replies.

13 replies

kolaai
Forum|alt.badge.img
  • monday.com Partner
  • August 6, 2021

Rating takes an object with a key string and a value string
Try this.

'classement' => {\\"rating\\" : \\"1\\"}

basdebruin
  • Community Expert
  • August 6, 2021

The rating object needs a number, not a string. So, I guess

'classement' => {\\"rating\\" : 1}

should do the job.


  • Author
  • Participating Frequently
  • August 6, 2021

Hello kolaai, " 'classement' => '{\\"rating\\" : \\"1\\"}', doesn’t work…


kolaai
Forum|alt.badge.img
  • monday.com Partner
  • August 6, 2021

Sorry, I was quoting from the documentation example


  • Author
  • Participating Frequently
  • August 6, 2021

Hi @basdebruin , I tried your suggestion such as :

    'classement' => '{\\"rating\\" : 1}',

and even

    'classement' => {\\"rating\\" : 1},

and it doesn’t work either.


  • Author
  • Participating Frequently
  • August 6, 2021

Thanks for trying to help…


basdebruin
  • Community Expert
  • August 6, 2021

This one works in my API playground. I propose you test it from there and make the necessary adjustments

mutation {change_column_value (item_id: 1111111111, board_id: 222222222, column_id: "rating", value: "{\\"rating\\": 2}") {id}}

When you want to combine with create_item this one works in the API playground

mutation { create_item (item_name: "New item", board_id: 22222222, column_values: "{\\"rating\\": {\\"rating\\": 2}}") {id}}


Forum|alt.badge.img
  • monday.com Team Member
  • August 6, 2021

Hi @big.th and everyone on this thread,

Thank you @kolaai and @basdebruin for your help here!

I believe the issue is as Bas stated, you need two rating keys in the column value that you’re sending. One is the column ID rating and the other is the key for the JSON you’re sending.

I see that there is a mistake in our documentation and the value should be an Int, not a String. Going to fix it now.

Let us know if this still does not work for you!


  • Author
  • Participating Frequently
  • August 12, 2021

Thanks @basdebruin, indeed it works in graphQL but still not from my PHP function. I keep working on it…


AlexSavchuk
Forum|alt.badge.img
  • monday.com Team Member
  • August 12, 2021

@big.th

I’m glad to hear @basdebruin’s suggestion was a step in the right direction, at least for the GraphQL playground! If you’d like, you can share your Python code with us here as well, and we could try tinkering and fine-tuning it to a working state from there.

Here’s what Postman outputs for a Python - Requests code snippet:

import requests
import json

url = "https://api.monday.com/v2"
payload = json.dumps({
  "query": "mutation { create_item (item_name: \\"New item\\", board_id: boardId, column_values: \\" {\\\\\\"rating\\\\\\": {\\\\\\"rating\\\\\\": 2}} \\") {id}}"
})
headers = {
  'Authorization': 'yourApiKey',
  'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

  • Author
  • Participating Frequently
  • August 12, 2021

Finally, I’ve just found !!! I post it here so it can help…

 $array = [
     'classement' => [ "rating" => 1 ],
 ];

AlexSavchuk
Forum|alt.badge.img
  • monday.com Team Member
  • August 12, 2021

@big.th

Amazing, i’m glad you were able to sort this out 🙂

Hope your development is a smooth sail from here on out. 🛥️

-Alex


  • August 19, 2021

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