大家好!我在请求删除 1C 中的项目时处理响应时遇到问题:通过 OData 管理我们的公司
这是我的代码:
def delete(entity, guid):
"""
Function to delete a specific entity by its GUID.
:param entity: Name of the entity
:param guid: GUID of the entity
"""
url = f'''http://localhost/mc/odata/standard.odata/{entity}(guid'{guid}')'''
headers = dict(Accept='application/json')
response = requests.delete(url, auth=(username, password), headers=headers)
print(response)
print(response.status_code)
try:
json_response = response.json()
except:
raise Exception(response.text)
if 'odata.error' in json_response:
raise Exception(json_response['odata.error']['message']['value'])
delete(entity='Catalog_Номенклатура', guid='0717035b-480b-11ef-a302-00155d550200')
在其他请求(创建/编辑)中,请求执行成功后,返回状态200,但这里是204,但该项目被删除。有没有办法处理响应以确保对象被 100% 删除?因为204看起来有点不健康
204 No Content - 服务器成功处理了请求,但响应仅包含标头,没有消息正文