I have tried every which way to send the below request but I either get a 500 response (Internal Server Error) when I send the book_token in as a string or the below error when I send it in as a dictionary:
"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/http/client.py", line 1049, in _send_output chunk = f'{len(chunk):X}\r\n'.encode('ascii') + chunk \ TypeError: can't concat str to bytes
The request works in POSTMAN (The suggested code does not though) and BURP SUITE so I believe that it is a configuration issue in my Python Code but I have no idea where. Any help would be amazing thank you!
Python Code
# Request: Book Reservation
conn = http.client.HTTPSConnection("api.resy.com")
payload = f"book_token={urllib.parse.quote_plus(book_token)}&struct_payment_method={urllib.parse.quote_plus(struct_payment)}&source_id=resy.com-venue-details"
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Resy-Auth-Token': x_resy_token,
'Authorization': auth_token,
'X-Resy-Universal-Auth': x_resy_token,
}
conn.request("POST", "/3/book", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Burp Suite Request
POST /3/book HTTP/2
Host: api.resy.com
Content-Length: 871
Sec-Ch-Ua:
X-Origin: https://widgets.resy.com
Sec-Ch-Ua-Mobile: ?0
X-Resy-Auth-Token: <MY_TOKEN>
Authorization: <MY_TOKEN>
User-Agent: <STUFF>
Chrome/115.0.5790.110 Safari/537.36
X-Resy-Universal-Auth: <MY_TOKEN>
Content-Type: application/x-www-form-urlencoded
Accept: application/json, text/plain, */*
Cache-Control: no-cache
Sec-Ch-Ua-Platform: ""
Origin: https://widgets.resy.com
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://widgets.resy.com/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
book_token=<TOKEN>&struct_payment_method=<MY_TOKEN>&source_id=resy.com-venue-details
Conclusion
I have tried using both the requests package and http.client and organizing the request in every way I can think of but nothing works