Can't post a new book/item to awesomebox.io scan page, wrong payload
<p>I'm having problems to post a new book/item at <a href="http://www.awesomebox.io/scan" rel="nofollow">http://www.awesomebox.io/scan</a>
If I do it manually at the website it works. And I see the post request, with a status 200</p>

<p>But with my python script im getting a status 400.</p>

<p>Anyone has a idea/solution or a working code example?
Wrong payload? or do i need the javascript to post/add a new book/item???</p>

<p>My code so far: </p>

<pre><code>from lxml import html
import requests
import re

# Make session
session = requests.session()

# Define login page
loginURL = 'http://www.awesomebox.io/login'

# Get login page and build tree
loginpage = session.get(loginURL)

# Get the csrfmiddlewaretoken value from the login page
m = re.search('(?&lt;=value=\')\w+', loginpage.text)
token = m.group(0)

# Post the payload to login in.
payload = {'csrfmiddlewaretoken': token , 'username': '******','password': '******'}
login = session.post(loginURL, data=payload)

# Session is now logged in, try to post/add a new book.
# Also manually possible at http://www.awesomebox.io/scan
additem = 'http://www.awesomebox.io/services/new-item/'
payload2 = {'csrfmiddlewaretoken': token ,'barcode': '9780321884916','branch': 'main' }

# Post the payload to add a new item/book
itempost = session.post(additem, data=payload)
print itempost.status_code
</code></pre>