Part 17 :POST Method Example REST API JSONPLACEHOLDER using Python requests library

Опубликовано: 13 Июнь 2026
на канале: AppSmashers
670
2

POST Method Example REST API JSONPLACEHOLDER using Python requests library

import requests
import json

urlpost='https://jsonplaceholder.typicode.com/...
bodypost={
'title': 'foo',
'body': 'bar',
'userId': 1
}

headerpost={'Content-type': 'application/json; charset=UTF-8'}
response=requests.post(url=urlpost,headers=headerpost,json=bodypost,)
status=response.status_code
print(status)
assert status==201
jsonObject=response.json()
print(jsonObject['id'])
print(jsonObject)