What is required to pass in the Looker Update an Alert API request?

I am trying to make a change to a Looker alert via API, but I am encountering the following error:

PUT /alerts/49 (422: Unprocessable Entity) Seconds: 0.271
 Body (325 bytes)
{
 "message": "Validation Failed",
 "errors": [
{
"field": "alert",
"code": "invalid",
"message": "field_selection_filter must contain :field_name",
"documentation_url": "https://cloud.google.com/looker/docs/r/err/4.0/422/put/alerts/:alert_id"
 }
],
 "documentation_url": "https://cloud.google.com/looker/docs/r/err/4.0/422/put/alerts/:alert_id"
}

 

This field called field_selection_filter does not appear in the example provided by Looker and I don't know how to use it.

If anyone has a ready-made template of what mandatory items I should pass in this request,
it will help me a lot.

Thank you all in advance for your attention.

Solved Solved
0 6 85
1 ACCEPTED SOLUTION

You might need to reference filter_name, title etc a bit differently. Identifying the table etc the filter comes from ie: 

Screenshot 2024-07-09 at 1.23.40 PM.png

View solution in original post

6 REPLIES 6

Hi there! Have you explored Lookers API explorer? I find the docs here can be a bit clearer. To update an alert, you will need these fields:

  • owner_id
  • field
  • destinations
  • comparison_type
  • threshold
  • cron

Hi, Amanda! Thanks for responding.

I read the documentation, but I couldn't find anything relevant about the field_selection_filter field, which seems to be the field related to the problem.

I imagine that this field has to do with the required field, but I have already tried declaring the field_selection_filter field inside and outside the field, but I have not been successful

Can you post url whole PUT request that you are sending through?

Sure:

{
"applied_dashboard_filters": [
{}
],
"comparison_type": "GREATER_THAN",
"cron": "1 4 * * *",
"custom_url_base": "",
"custom_url_params": "",
"custom_url_label": "",
"show_custom_url": false,
"custom_title": "",
"dashboard_element_id": "111",
"description": "",
"destinations": [
{
"destination_type": "EMAIL",
"email_address": "(PII Removed by Staff) @gmail.com"
}
],
"field": {
"title": "Qualquer Contagem de Is Anomaly (Yes / No)",
"name": "contagem_de_is_anomaly_yes_no",
"filter": [
{}
]
},
"followed": true,
"followable": false,
"is_disabled": false,
"disabled_reason": "",
"is_public": false,
"investigative_content_type": "",
"investigative_content_id": "",
"lookml_dashboard_id": "",
"lookml_link_id": null,
"owner_id": "11",
"owner_display_name": "Janderson",
"threshold": 0,
"time_series_condition_state": {
"previous_time_series_id": "",
"latest_time_series_id": ""
}
}

You might need to reference filter_name, title etc a bit differently. Identifying the table etc the filter comes from ie: 

Screenshot 2024-07-09 at 1.23.40 PM.png

I removed the applied_dashboard_filters field and the code worked. I was using it unnecessarily since I didn't need a filter.

Thank you very much!