Answer the question
In order to leave comments, you need to log in
How to send json in POST request?
Hello!
Tell me, please, I need to send a POST request like this (example):
{
"document": {
"birthDate": "1989-11-19",
"lastName": "Симонов",
"firstName": "Владимир",
"middleName": "Иванович"
}
import requests
import json
name =input("Введите Фамилию:")
surname =input("Введите Имя:")
middlename =input("Введите Отчество:")
birthday =input("Введите дату рождения(ГГГГ-ММ-ДД):")
url = '*******'
headers = {'token': '*************'}
data = {"document": {
"birthDate": birthday,
"lastName": surname,
"firstName": name,
"middleName": middlename}
}
r = requests.post(url, headers=headers, json=data)
Введите Фамилию:Симонов
Введите Имя:Владимир
Введите Отчество:Иванович
Введите дату рождения(ГГГГ-ММ-ДД):1989-11-19
Симонов Владимир Иванович 1989-11-19
b'{"document": {"birthDate": "1989-11-19", "lastName": "\\u0412\\u043b\\u0430\\u0434\\u0438\\u043c\\u0438\\u0440", "firstName": "\\u0421\\u0438\\u043c\\u043e\\u043d\\u043e\\u0432", "middleName": "\\u0418\\u0432\\u0430\\u043d\\u043e\\u0432\\u0438\\u0447"}}'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question