Hi
I'm running a newman json file. It's a post request sending a file to servers.
I successfully run this same request on Postman client. But I don't know how to attach a file with newman.
I've tried this post:https://www.getpostman.com/docs/run_file_post_requests
But it's not working to me.
newman -c testfile.json
Here is the json file
{
"id": "d84a975c-5232-cec2-dd15-1e2c7d416523",
"name": "Test",
"description": "",
"order": [
"e534d07c-6024-6cac-cc00-2dabf3ce0985"
],
"folders": [],
"timestamp": 1469168677509,
"owner": "205566",
"remoteLink": "",
"public": false,
"published": false,
"requests": [
{
"id": "e534d07c-6024-6cac-cc00-2dabf3ce0985",
"headers": "",
"url": "http://url",
"preRequestScript": null,
"pathVariables": {},
"method": "POST",
"data": [],
"dataMode": "binary",
"version": 2,
"tests": "tests[\"Status code is 200\"] = responseCode.code === 200;",
"currentHelper": "normal",
"helperAttributes": {},
"time": 1469170668826,
"name": "name"",
"description": "",
"collectionId": "d84a975c-5232-cec2-dd15-1e2c7d416523",
"responses": [],
"rawModeData": ""
}
]
}
Hope get your reply soon, thanks!
Hi guys!
It will be awesome if you could support base64-encoded file content in json (as binary data).
馃憤
since we stream upload and ensure we do not read the entire file at one go (performance), the encoding will only happen in chunks. this might not result in same output. need to see if we can reserve a chunk and ensure the concatenation point of two chunks are accurate.
@a85 FYI.
Regarding the original question, export the collection in v2 format from postman app and ensure that the file references are mentioned as path in a key called src.
@shamasis it doesn't work in raw mode even though it does in form-data mode. Still stuck with my tests I can't automate posting binary file in raw mode.
ok so in terms of v2 json is the following the expected format to stream a file?
I have tried a few permutations and I cannot get it to work.
"body": {
"mode": "raw",
"src": "/path/filename.xml"
},
If the v2 format does now work with binary is there possibly a way to do it with v1?
"data": [],
"dataMode": "binary",
how is the filepath specified within data??
@czardoz @kunagpal - 馃憜馃徏
Can you try by setting the mode to "file" in v2?
nice file worked... I had to use "file" though in both lines including the key/value for path
"body": {
"mode": "file",
"file": "/path/filename.xml"
},
works for me too using the same structure as @gsterg (thx by the way)
By the way, this is actually a bug. It should read from mode: file and src:path/to/file.
Hope it is okay for you to change it back when we fix this. In fact, care will be taken to close this issue only AFTER a release has been done with this fix, so that you can track and update when you can. Apologies in advance.
@czardoz FYI
that's fine for me @shamasis
Tried the way that @gsterg used and am getting 501 Not implemented. Any body else getting that?
@tslape, that's a server response usually returned when you use a wrong HTTP method (GET instead of POST, etc). Can you open a new issue if you're having trouble? My guess is that your issue is not related to this one :)
@tslape - can you check if you could otherwise upload file using Postman clients. Is it possible to debug why your server is returning not inplemented.
It could either be that Newman is sending the API in a format your server does not support but Postman app is doing it right - if so, we should investigate this (possibly in a new issue and not in this one)
If not (I.e. The request fails on both postman and Newman) then we need to verify that your server is not acting up
@czardoz @shamasis I opened a new ticket #621 and it works in the Chrome Extension, but not in Newman or the Windows Application
Closing this issue on our end, work is still in progress on #621.
Hi, is there already a solution for this issue? I tried mode: file and src: /path/to/file, but it doesn't work...
Hey @pietervanneste, could you share your collection and associated (environment, data, globals) files, without the sensitive details?
Hi @kunagpal, here is an example of my collection: https://www.getpostman.com/collections/464e0ccb2e01e64d52bf
It's a PUT request with a binary body that works successfully in Postman. But if I try to export the collection (v2) from Postman for Newman usage. I get something like this as body:
"body": {
"mode": "raw",
"raw": ""
}
How can I make it work in Newman? I already tried
"body": {
"mode": "file",
"file": "/path/filename"
}
and
"body": {
"mode": "file",
"src": "/path/filename"
}
But nothing seems to work. Can you tell me what I'm doing wrong :-) ?
Hey @pietervanneste, which version of the Postman Client (Chrome, or native) are you on? When exported with v4.8.3 in form-data mode, the following structure is seen:
.
.
.
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"src": "path/filename",
"type": "file",
"value": ""
}
]
}
.
.
.
Please try exporting your collection with the latest version and let us know how that works for you. :smile:
Hmm strange, I am on the same version (Chrome native extension v4.8.3) and get this output for exporting to collection v2:
{
"variables": [],
"info": {
"name": "newman",
"_postman_id": "2bc8b8cd-0302-5729-0861-68596bb81f82",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
"name": "PUT: binary file as body",
"request": {
"url": "https://some.url/",
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "Bearer TOKEN",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": ""
},
"description": ""
},
"response": []
}
]
}
I tested also on my college's laptop. Same result. For testing I replaced my body with yours. But the upload failed because it expects binary data.
Are you sure that you export the request with a body as 'binary'?

@pietervanneste The example was for exports in form-data mode. It appears that the app is not adding the file path for binary mode. @madebysid :point_up:
@kunagpal: Can I do that manually by replacing the body with the correct syntax?
@pietervanneste We're investigating this on our end as well. As a temporary workaround, please set body.mode to "file", and body.file to "path/filename". We'll notify you when any changes happen on this.
@kunagpal any update on the ability to add a file path for binary data in the body? It would answer this as well http://stackoverflow.com/questions/39576110/sending-binary-data-with-postman-and-newman
I have to upload document using binary in postman.How can I do??
Is there any update for this? My problem is the same of @pietervanneste.