![]() |
Error posting with requests - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Error posting with requests (/thread-25380.html) |
Error posting with requests - julio2000 - Mar-28-2020 So I've created a code that posts something on a website. It works perfectly fine when I run it like this (+ other code but that isnt important): # Above is other (correct) code, wich isnt important payload = { "firstName": self.first_name, "lastName": self.last_name, "email": "[email protected]", "dateOfBirth": self.dob, "termsAccepted": 'true', "variantId": int(self.size), "articleId": int(self.url), } response = requests.post(url2, payload, proxies=proxies) print(response.status_code)It prints out '200', so this code works. But when I run it with the (SAME) email being a variable. So like this: # Above is other (correct) code, wich isnt important payload = { "firstName": self.first_name, "lastName": self.last_name, "email": self.email, "dateOfBirth": self.dob, "termsAccepted": 'true', "variantId": int(self.size), "articleId": int(self.url), } response = requests.post(url2, payload, proxies=proxies) print(response.status_code)it prints out (500), with the reason: internal server error. Does someone know why? RE: Error posting with requests - buran - Mar-28-2020 If I have to guess - self.email value is not what you expect :-)Also, if you print response.text it may have more information RE: Error posting with requests - julio2000 - Mar-28-2020 I tried. I did: print(self.email)and it printed out [email protected] RE: Error posting with requests - buran - Mar-28-2020 try print(repr(self.email)) to check for any non-printing characters
RE: Error posting with requests - julio2000 - Mar-28-2020 it printed out this: '[email protected]' I've tried it with this email: [email protected], and it worked. So i think it's that 2 that screws it up. But i need my script to work with emails like: [email protected] too. So I do need a fix RE: Error posting with requests - buran - Mar-28-2020 initially you claimed it worked with same address... Now it turns it was not the same. what is the result if you try the first snippet with the SAME e-mail address. or whas it working with self.email='[email protected]'? Also what url/API you send request to (i.e. are there any docs)? RE: Error posting with requests - julio2000 - Mar-28-2020 It was the same address......... I've tried it too with a different addres, but that did work. but when I used the same addres but as a variable, it didnt work. (Mar-28-2020, 09:43 PM)julio2000 Wrote: It was the same address.........It DID work with self.email = '[email protected]'. And it DIDN'T work with self.email = '[email protected]' so no one knows the answer?.... |