Using urllib2 to request urllib2.HTTPError 422 error under python?

problem description

use urllib2 to request urllib2.HTTPError 422 error under

python

the environmental background of the problems and what methods you have tried

No exception was found for printing the requested url,data,header, etc. No relevant methods were found on the Internet

related codes

/ / Please paste the code text below (do not replace the code with pictures)

request_headers = {"Content-type": "application/json", "X-Auth-Token": auth_msg.token_id}
request_data = single_cal_node.__dict__
result = http_post(url, request_data, request_headers)
def http_post(url, data_json, headers):
    """
    :param url:       Url
    :param data_json: data_json
    :param headers:
    """
    data_json_str = None
    if data_json is not None:
        data_json_str = json.dumps(data_json)
    -sharp 
    if headers is None:
        headers = default_headers
    req = urllib2.Request(url, data_json_str, headers=headers)

    response = urllib2.urlopen(req)
    return response.read()

what result do you expect? What is the error message actually seen?

expect the request to succeed and return the correct information. Error message urllib2.HTTPError: HTTPError 422: Unprocessable Entity

Dec.23,2021

who knows the answer? Code yourself

< hr >

has been processed and found that the problem is that the parameter I requested is one level less. After modification, you can

Menu