使用Python的odesk API POST作业

使用Python的odesk API POST作业,python,api,odesk,Python,Api,Odesk,我正在尝试使用他们的API将作业发布到odesk帐户。不幸的是,我很难做到这一点 我能够得到身份验证并获得我的工作,但当我尝试发布工作时,它返回400错误 这是回应体 HTTP Error 400: Bad Request Exception at POST https://www.odesk.com/api/hr/v2/jobs.json Server: nginx Date: Thu, 11 Oct 2012 21:38:08 GMT Content-Type: application/js

我正在尝试使用他们的API将作业发布到odesk帐户。不幸的是,我很难做到这一点

我能够得到身份验证并获得我的工作,但当我尝试发布工作时,它返回400错误

这是回应体

HTTP Error 400: Bad Request
Exception at POST https://www.odesk.com/api/hr/v2/jobs.json
Server: nginx
Date: Thu, 11 Oct 2012 21:38:08 GMT
Content-Type: application/json
X-Odesk-Error-Code: 4
X-Odesk-Error-Message: Parameter job_data is missing or invalid
Last-Modified: Thu, 11 Oct 2012 21:38:08 GMT
Accept-Ranges: bytes
Cache-Control: no-store
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Transfer-Encoding: chunked
Connection: close
我也在使用python odesk。 我跟着这个到了T,我得到了上面的错误。

对此进行了讨论: 但我认为这还没有解决

我甚至试着通过邮递员发送邮件,我收到了: “未填写所有必需的参数”

我已尝试将以下数据包发送到odesk。 假设XXXXXX是有效的买方团队参考

    data = {
            'buyer_team__reference': XXXXXX,
            'title': 'Test job from API',
            'job_type': 'hourly',
            'description': 'this is test job, please do not apply to it',
            'visibility': 'invite-only',
            'category': 'Web Development',
            'subcategory': 'Web Programming',
            'budget': 10,
            'duration': 7,
    }

注意:我已经尝试了许多类似包的变体,但没有成功

如果有人有任何语言的odesk API的经验,任何帮助都将是巨大的

谢谢。

尝试之后,我放弃了,改用mechanize将招聘信息自动发布到敖德克

执行
pip安装mechanize

import mechanize,cookielib
# Browser
br = mechanize.Browser()

# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)

# Browser options
br.set_handle_equiv(True)
br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)

# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)

# Want debugging messages?
#br.set_debug_http(True)
#br.set_debug_redirects(True)
#br.set_debug_responses(True)

# User-Agent (this is cheating, ok?)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]

# Open odesk site
r = br.open('https://www.odesk.com/login.php')
form = br.forms().next()  # the login form is unnamed...
print form.action
form['login'] = 'yourlogin'
form['password'] = 'yourpassword'
br.form = form
br.submit()

print br.geturl()
#your form data goes here
r = br.open(br.geturl() + 'new/')
print br.geturl()
br.select_form(name="jobsPost")  # the form is unnamed...
br.find_control(name="category").value = ['Writing & Translation']
br.find_control(name="subcategory").value = ['35']
br.form['title'] = 'Filling up a profile'
br.form['description'] = 'Require assistance in filing up our profile'
br.find_control(name="job_type").value = ['Fixed']
br.form['job_budget'] = '10'
br.form['job_finish_date'] = '10-14-2012'
br.find_control(name="visibility").value = ['private']
br.submit()

print br.geturl()
import mechanize,cookielib
# Browser
br = mechanize.Browser()

# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)

# Browser options
br.set_handle_equiv(True)
br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)

# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)

# Want debugging messages?
#br.set_debug_http(True)
#br.set_debug_redirects(True)
#br.set_debug_responses(True)

# User-Agent (this is cheating, ok?)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]

# Open odesk site
r = br.open('https://www.odesk.com/login.php')
form = br.forms().next()  # the login form is unnamed...
print form.action
form['login'] = 'yourlogin'
form['password'] = 'yourpassword'
br.form = form
br.submit()

print br.geturl()
#your form data goes here
r = br.open(br.geturl() + 'new/')
print br.geturl()
br.select_form(name="jobsPost")  # the form is unnamed...
br.find_control(name="category").value = ['Writing & Translation']
br.find_control(name="subcategory").value = ['35']
br.form['title'] = 'Filling up a profile'
br.form['description'] = 'Require assistance in filing up our profile'
br.find_control(name="job_type").value = ['Fixed']
br.form['job_budget'] = '10'
br.form['job_finish_date'] = '10-14-2012'
br.find_control(name="visibility").value = ['private']
br.submit()

print br.geturl()