Forum Discussion
Thank you, Diane. Unfortunetly, FileName is not coming through after Json Parser and therefore, there is no way to get to it in JSON Splitter.
ZipFile Read produces following output:
JSON Parser follows directly after ZipFile Read and outputs only content of the data file itself:
Therefore, JSON Path does not have FileName:
Any ideas how I can pass FileName from ZipFile Read to JSON Parser and then to JSON Splitter?
Thank you!
Correct, it would not come through this way. My apologies for not including an image early. My intent was to collect the information earlier in the pipeline, Copy it out to a second branch, then join it back in with a Join or Union, whichever is appropriate for the data.
As @tstack said, there are several ways to do the same thing.
- bojanvelevski3 months agoValued Contributor
Hi jfpelletier,
The problem is that in the Python script, you're not just sending the file as multi part form data, you're also sending a content, a payload saying {'fileName': 'fileName.jpg'}. You basically send 2 different payloads JSON and Binary (the very image itself). When the multipart reader snap collects your request, it pulls the JSON first:
And that document doesn't have a content-type attached to it, so your next snap, the binary router, is failing.
Basically, your request from Postman is not sending an additional payload to change the name of the target file, that's why it is passing successfully. Just remove the data=payload part of the request in the script and you'll get the same result in the Postman request.
I hope this helps. If not, let us know.
Regards,
Bojan
- jfpelletier3 months agoContributor
Hello bojanvelevski,
Thanks for your reply! There is one part of your reply that I don't really understand, that is if I remove the "data=payload" part of the request, then how can I also supply a JSON payload at the same time as my file?
The payload includes the name we want to give to the returned files in response (the API takes in one file, does some manipulation, then returns another file). Other parameters will eventually be passed via this payload.
Kind regards,
JF
- bojanvelevski3 months agoValued Contributor
How do you send the name via Postman?
- jfpelletier3 months agoContributor
I send the name as text value in a form-data (and the file as a file value in the same form-data)
- bojanvelevski3 months agoValued Contributor
import requests
url = "https://MyURL.com?bearer_token=abc123"
files=[
('file',('fileName.png',open('file.png','rb'),'image/png'))
]
headers = {}response = requests.request("POST", url, headers=headers, files=files)
print(response.text)
Try this. The first argument in the file line should be the target filename you want to use. Let me know if this helps.
Regards,
Bojan
Related Content
- 6 months ago
- 3 years ago