I am practicing making requests to APIs with Python. I am currently practicing with this API found on GitHub: https://github.com/vdespa/introduction-to-postman-course/blob/main/simple-books-api.md.
I would like to make a POST request to order a book. To make this request I provide an int book ID and a str customer name. However, the response I am getting is consistently "Invalid or missing bookId".
But when I use Postman to make this same request it works, responding with a True boolean and a str order ID. It also works when I use cURL and my terminal.
Any help would be appreciated! Thank you. :)
import requests
import json
order_url = "https://simple-books-api.glitch.me/orders"
my_post_1 = {"bookId" : 1,
"customerName" : "Anna"}
header_1 = {"Authorization" : my_token}
post_text_1 = requests.post (order_url, data = my_post_1, headers = header_1)
print ("status:", post_text_1)
print ("respose:", post_text_1.text)