0

I am trying to create a request in the pre-request script using in the form-data and in the body i would like to upload a pdf file from my working directory.

I used the following script and the file is not attached in my script. Can you please help me to identify my problem?

"body":{ 
        "mode": "formdata",
        "formdata": [
            { "key" : "file","value": "X:\\Postman\\files\\test.pdf", "disabled" : false, "description" : {"content" :"", "type" :"file"}},
            { "key" : "text","value": "text", "disabled" : false, "description" : {"content" :"", "type" :"text"}},
            { "key" : "Number","value": "12345686", "disabled" : false, "description" : {"content" :"", "type" :"text"}},
            { "key" : "Text","value": "0011002327", "disabled" : false, "description" : {"content" :"", "type" :"text"}},  
            { "key" : "Date","value": "02/12/2020", "disabled" : false, "description" : {"content" :"", "type" :"text"}}
        ]}  
Michele Pisani
  • 13,567
  • 3
  • 25
  • 42
  • Does this answer your question? [How to set the request body via Postman's pre-request script?](https://stackoverflow.com/questions/50715532/how-to-set-the-request-body-via-postmans-pre-request-script) – Mushroomator Sep 07 '22 at 11:33

1 Answers1

0

In case of file, KEY name should be src instead of value

eg- "src": "X:\\Postman\\files\\test.pdf"

otherwise it will treated as a text not as file path

kindly refer screenshot for the same