Я пытаюсь обновить контакт в обмен на онлайн с помощью outlook rest API.Я могу создать контакт, используя сообщение.Я также проверил патч, который работает нормально.Тем не менее, когда я отправляю запрос PUT
, он не работает.
Так вот мой код:
def update_contacts():
# / ContactsFolders/{folder_id}/contacts
contact_id = "AAMkADAzNTg5ZjFmLWI2OTItNDFiOC1iNzg5LTNmOTJmOGUxYmUxNwBGAAAAAABMzp004WaZQqK4q_HRlSK9BwAqlNNaGOnjR7gnbsbOcpkFAAJm6kCDAAAqlNNaGOnjR7gnbsbOcpkFAAJm6m_3AAA="
url = "https://outlook.office365.com/api/v2.0/users('{email_id}')/contacts/{contact_id}"
#data = {"GivenName": "C1_Updated_put", "DisplayName": "MyRestApiContactFolder1"}
data = {
"Categories": [],
"Birthday": None,
"FileAs": "",
"DisplayName": "MyRestApiContactFolder1",
"GivenName": "C1_Using_Put",
"Initials": None,
"MiddleName": None,
"NickName": None,
"Surname": None,
"Title": None,
"YomiGivenName": None,
"YomiSurname": None,
"YomiCompanyName": None,
"Generation": None,
"ImAddresses": [],
"JobTitle": None,
"CompanyName": None,
"Department": None,
"OfficeLocation": None,
"Profession": None,
"BusinessHomePage": None,
"AssistantName": None,
"Manager": None,
"HomePhones": [],
"MobilePhone1": None,
"BusinessPhones": [],
"SpouseName": None,
"PersonalNotes": "",
"Children": [],
"EmailAddresses": [],
"HomeAddress": {
"Type": "Unknown"
},
"BusinessAddress": {
"Type": "Unknown"
},
"OtherAddress": {
"Type": "Unknown"
}
}
req = url.format(email_id=email_id, contact_id=contact_id)
resp = requests.put(url=req, json=data, headers=HEADERS)
#print(HEADERS)
print(resp)
resp = resp.json()
print(resp)
Вот мой заголовок для запроса -
def set_headers():
global HEADERS
token_resp = get_token(email_id).json()
access_token = token_resp.get('access_token')
HEADERS['Authorization'] = 'Bearer '+ access_token
HEADERS["content-type"] = "application/json"
HEADERS['accept'] = "application/json"
HEADERS['X-AnchorMailbox'] = email_id
#print(HEADERS)
Это response(405)
с использованием операторов print:
<Response [405]> {u'error': {u'message': u'The OData request is not
supported.', u'code': u'ErrorInvalidRequest'}}