I am submitting media processing jobs to a media transcode API.
It is REST based and accepts a few values in the call:
- workflowIdentifier (required): unique ID to the API, this is static
- sourceFilename (required): url encoded samba UNC path
- jobName (optional): string
- context (optional): This is an XML payload read by the API
Here is what an example manual submit would look like (with much of the XML truncated for readability)
POST http://1.1.1.1:1234/SubmitRest/SubmitFile?workflowIdentifier=4r5t6y7u&sourceFilename=%5C%5C10.10.1.20%5Cteststore%5Cmedia%5CTEST001E1.mov&jobName=mytestjob&context=%3CContext+xmlns%3D%22http%3A%2F%2FTelestream.Vantage.Sdk%2F2010%2F07%22+xmlns%3Ai%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchem... When the XML (for context) is small enough THIS WORKS
However in our production environment it's a VERY large XML payload to be sent to "context" so I'm getting:
<hr><p>HTTP Error 414. The request URL is too long.</p> - So after doing a bit of searching, I've tried the following
context_string = (the very large XML document as a string) source_file = '%5C%5C10.10.1.20%5Cteststore%5Cmedia%5CTEST001E1.mov' job_name = 'testjob' workflow_id = '4r5t6y7u' url = 'http://1.1.1.1:1234/SubmitRest/SubmitFile?workflowIdentifier=' + workflow_id + '&sourceFilename=' + source_file + '&jobName=' + job_name reply = requests.post(url, data={'context': context_string}) The job is successfully accepted by the API, BUT the context payload is ignored.
(Please note that I've tried with the XML url encoded, and as a normal string )
I also tried it like this:
context_string = (the very large XML document as a string) source_file = '%5C%5C10.10.1.20%5Cteststore%5Cmedia%5CTEST001E1.mov' job_name = 'testjob' workflow_id = '4r5t6y7u' payload = {'workflowIdentifier': workflow_id, 'sourceFilename': source_file, 'context': context_stringa, 'jobName': jobname} reply = requests.post(url, data=payload) This doesn't work at all, it fails since the required fields are not found (such as workflowIdentifier
Totally stumped on why it is working when I can fit all the data into the one URI, but it doesn't work when I try and add it to a payload with requests(data=)
So my main question is -- how can I submit this via python requests just like if it was all part of the URI POST call? I must be doing something wrong here.
No comments:
Post a Comment