Unauthorised field or type error when calling create_notification mutation

When I try to execute this mutation in my code, I get the following error:

Mutation:

    const query = `mutation create_notification($userId: ID!, $targetId: ID!, $text: String!, $targetType: NotificationTargetType!) {
      create_notification(user_id: $userId, target_id: $targetId, text: $text, target_type: $targetType) {
        text
      }
    }`;

      targetType = "Post",
      userId = 12345678,
      targetId = 2456768,
      text = "<b>test notification</b>"


    const variables = { userId, targetId, text, targetType };

    const response = await this.mondayClient.execute(query, variables);

Error

  {
   "text": {
       "errors": [
             {
                     "message": "Unauthorized field or type",
                     "path": [
                               "create_notification"
                             ],
                     "extensions": {
                               "code": "UNAUTHORIZED_FIELD_OR_TYPE"
                             }
                   }
           ],
       "account_id": 12345678
     }
 }

cc: @dipro

The targetType is not of type string, it is of type NotificationTargetType! which is an enum type (Project of Post)

Yeah but that’s what I specified it as. Can you please provide an example of the correct way to pass the target type.

Thank you.

You are specifying a string “double quotes”, try the back ticks instead.

Now I get this error when I use backticks:

{
  text: {
    errors: [
      {
        message:
          "parsing error: syntax error: expected R_PAREN, got targetType",
        locations: [
          {
            line: 1,
            column: 76,
          },
        ],
        extensions: {
          code: "PARSING_ERROR",
        },
      },
      {
        message: "parsing error: syntax error: expected a Selection Set",
        locations: [
          {
            line: 1,
            column: 76,
          },
        ],
        extensions: {
          code: "PARSING_ERROR",
        },
      },
      {
        message:
          "parsing error: syntax error: expected a StringValue, Name or OperationDefinition",
        locations: [
          {
            line: 1,
            column: 86,
          },
        ],
        extensions: {
          code: "PARSING_ERROR",
        },
      },
      {
        message: "parsing error: syntax error: expected definition",
        locations: [
          {
            line: 1,
            column: 88,
          },
        ],
        extensions: {
          code: "PARSING_ERROR",
        },
      },
      {
        message:
          "parsing error: syntax error: expected a StringValue, Name or OperationDefinition",
        locations: [
          {
            line: 1,
            column: 110,
          },
        ],
        extensions: {
          code: "PARSING_ERROR",
        },
      },
      {
        message:
          "parsing error: syntax error: expected a StringValue, Name or OperationDefinition",
        locations: [
          {
            line: 1,
            column: 111,
          },
        ],
        extensions: {
          code: "PARSING_ERROR",
        },
      },
    ],
    account_id: 12345678,
  },
};

I was able to figure out the issue. I didn’t have the notifications:write scope.

Thanks for your help @basdebruin