A
A
Alexander Shilov2019-03-22 09:13:35
Python
Alexander Shilov, 2019-03-22 09:13:35

How to send a JSON HTTP request from Python?

Good day, toasters. You need to upload contacts to Outlook using Python tools. I found the necessary information on the Microsoft website . But I don’t quite understand how to send this HTTP request through Python. Thank you for your help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2019-03-22
@tabbols95

The easiest and most convenient way is - https://github.com/kennethreitz/requests

A
Andrew, 2019-03-22
@deepblack

Example code:

import requests

contacts_data = {
  "givenName": "Pavel",
  "surname": "Bansky",
  "emailAddresses": [
    {
      "address": "[email protected]",
      "name": "Pavel Bansky"
    }
  ],
  "businessPhones": [
    "+1 732 555 0102"
  ]
}
r = requests.post('https://graph.microsoft.com/v1.0/me/contacts', json=contacts_data)

Documentation here: docs.python-requests.org/en/master/user/quickstart

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question