Deadline python api

Hey Masters. I’m trying to create a simple python script connecting to google spreadsheets reading the sheet taking the info about the tasks we have (Job Name, Priority), and setting the Priority in Deadline.

So far so good. Google API all good.
Deadline API not so good. Script I’ve got so far:

import Deadline.DeadlineConnect as Connect
connectionObject = Connect.DeadlineCon('localhost', 8082)

job = connectionObject.Jobs.GetJob("5f7ebf38ef6fe947a0bcb4ae")
root = connectionObject.Repository.GetRootDirectory()
print (root)
print (str(job['Props']['Name']) + ' - ' +str(job['Props']['Pri']))

job['Props']['Pri'] = 77
connectionObject.Jobs.SaveJob(job)

Result:

//******/deadlinerepo
PROJECT_NAME - 100
Traceback (most recent call last):
  File "c:/Users/******/Desktop/Deadline Priority/Deadline_API.py", line 11, in <module>
    connectionObject.Jobs.SaveJob(job)
  File "c:\Users\******\Desktop\Deadline Priority\Jobs.py", line 70, in SaveJob
    return self.connectionProperties.__put__("/api/jobs", body)
  File "c:\Users\******\Desktop\Deadline Priority\ConnectionProperty.py", line 42, in __put__
    return DeadlineSend.pSend(self.address, commandString, "PUT", body, self.useAuth, self.user, self.password)
  File "c:\Users\******\Desktop\Deadline Priority\DeadlineSend.py", line 92, in pSend
    response = opener.open(request)
  File "C:\Users\******\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 524, in open
    req = meth(req)
  File "C:\Users\******\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 1248, in do_request_
    raise TypeError(msg)
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.

I’ve changed some of the Deadline API as well to make it even connect to web service.

Does anyone have an idea how to resolve this issue?

Python - 3.6.8

Thank you!

Hello!

Take a look at this Stackoverflow answer that looks really similar to your issue. The issue may also be that Deadline’s still written for python 2 and you’re running Python 3.

1 Like

Thanks Justin.

Yeah, I’ve re-write the Job.py from Deadline API and everything is working just fine!
Basically, on every “body” variable I’ve just added “.encode”

Glad it’s working! Be sure you’ve got a backup so any upgrades don’t blow away all your work!

1 Like
Privacy | Site terms | Cookie preferences