jfpelletier
3 months agoContributor
Multipart Reader failure - 'content-type' was not found
Hello all,
I'm successfully using Postman to submit a file and payload to a SnapLogic triggered task using the Multipart Reader snap, however when I try the same using Python, I'm getting an error like this one:
{
"failure" : "Pipeline execution failed while waiting for output",
"reason" : "Snap errors: {ruuid=653b762b58a6244b73fecf7a_1388887b-924e-4356-b1e6-b05868cf03bf, reason='content-type' was not found while evaluating the sub-expression '$['content-type']', label=Binary Router, resolution=Check the spelling of the property or, if the property is optional, use the get() method (e.g. $.get('content-type')), failure=$['content-type'] is undefined. Perhaps you meant: 'Content-Type', 'Content-Length', 'Connection', 'CONTENT_TYPE'}",
"resolution" : "Fix the reported errors"
}
The Python sample was generated by Postman and didn't include any 'Content-Type' defined:
import requests
url = "https://MyURL.com?bearer_token=abc123"
payload = {'fileName': 'fileName.jpg'}
files=[
('file',('file.png',open('file.png','rb'),'image/png'))
]
headers = {}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
I added the 'content-type' in the headers like below, but it doesn't change anything, I'm getting the same error.
import requests
url = "https://MyURL?bearer_token=abc123"
payload = {'fileName': 'fileName.jpg'}
files=[
('file',('file.png',open('file.png','rb'),'image/png'))
]
headers = {
'Content-Type' : 'image/png'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
I'm using the Multipart Reader snap the default values.
Does anyone know how to resolve this issue?
Thanks in advance for any help!
Kind regards,
JF
This error will occur if the key
"$"
does not exist in your 8th document. You can either:- change your expression to
$.get('$')
which will effectively produce anull
value for$['$']
downstream - or if your error is in a Mapper, you can also check the
checkbox, which will also produce a
null
value (but also applies null-safe to all the fields in your mapper).
- change your expression to