Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 11, 2021 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/0d7307ec61b81e06587bf2cbd32d2cca to your computer and use it in GitHub Desktop.
Save parzibyte/0d7307ec61b81e06587bf2cbd32d2cca to your computer and use it in GitHub Desktop.
# https://parzibyte.me/blog
import requests
url = "https://jsonplaceholder.typicode.com/posts"
usuario = {
"title": "Título",
"body": "El cuerpo",
}
respuesta = requests.post(url, json=usuario)
# Ahora decodificamos la respuesta como json
como_json = respuesta.json()
print("La respuesta del servidor es:")
print(como_json)
# Podemos acceder al id por ejemplo
id = como_json["id"]
print(f"El id es: {id}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment