pico @pico

how does posting with APIs work?

Dec 10, 2023, 9:40 PM
9
View all Parent

comments

Highlighted comment

Are you making a POST request or a GET request?

I first want to get my auth token, how do I get that? POST or GET?

Python code:

import requests

import json

url = "https://api.wasteof.money/login"

body = {"username": "dea", "password": "ThisIsMyWorld"}

response = requests.post(url, json=body)

# Beautify the output result

print("Status Code:", response.status_code)

print("Headers:")

print(json.dumps(dict(response.headers), indent=2))

print("Response Body:")

print(json.dumps(response.json(), indent=2))

POST, also the URL for that is /session

perfectly working now, thanks!

no problem!