What causes a 422 response in the API?

Knowledge Drop

Last tested: Mar 25, 2019
 

As per this document, a 422 occurs when the API is able to recognize that the endpoint exists but Looker can't process the request because a required parameter is missing, or one or more of the given parameters contains an invalid value. This can happen when a you attempts to run a Look/Dashboard/Scheduled Plan with an destination type that doesn't exist, or if you're using a parameter combination that is invalid.

The best way to figure out what's going on is to look at the body of the 422 response - Looker generally provides very specific and detailed information about multiple problems found with the request when returning a 422 response.

Once you post the body of the HTTP response in a word editor of your choice you'll most likely realise the cause of the error before contacting us in support. For example, in the past, a user that saw this error had used this as a body:



"name": "test_bcp_1", 

"user_id": 88, 

"run_as_recipient": false, 

"enabled": true, 

"dashboard_id": 153, 

"require_results": false, 

"require_no_results": false, 

"require_change": false, 

"send_all_results": true, 

"scheduled_plan_destination": [ 



"format": "assembled_pdf", 

"apply_formatting": true, 

"apply_vis": true, 

"address": "redacted", 

"type": "email", 

"can": {} 



], 

"run_once": true, 

"include_links": true, 

"pdf_paper_size": "A4", 

"pdf_landscape": false, 

"embed": true, 

"long_tables": true, 

"can": {} 

And the response looked like:



"message": "Validation Failed", 

"errors": [ 



"field": "dashboard_id", 

"code": "invalid", 

"message": "Cannot send all results for dashboards" 

}, 



"field": "format", 

"code": "invalid", 

"message": "format assembled_pdf invalid -- valid formats for unlimited Dashboard sent as 'email' are [:txt, :csv, :json, :xlsx, :html]" 



], 

"documentation_url": "
http://docs.looker.com/

In this case, we saw the 422 occur because we were trying to send all results for a dashboard that was scheduled as an assembled_pdf which isn't possible in Looker. Thus, Looker knew what the call was, knew the syntax was correct, but threw a 422 because it couldn't process the request.

This content is subject to limited support.                

Version history
Last update:
‎07-07-2021 01:16 PM
Updated by: