Forum Discussion

pb9034's avatar
pb9034
New Contributor
7 months ago

use single request field for string as well as file

i want to use a single request field to take string and file both which one i want

3 Replies

  • Hi pb9034,

    Can you please clarify how I can help you and what you want to achieve? Having an example, description, or screenshots would be helpful. 

  • pb9034's avatar
    pb9034
    New Contributor

    want to use description input to be text or image according to my need as postman provides option to chose between text or file

    using like this:

     content:

     *         multipart/form-data:

     *           schema:

     *             type: object

     *             properties:

     *               title:

     *                 type: string

     *                 example: sample title

     *               resource_type:

     *                 type: integer

     *                 enum: [1, 2, 3]

     *                 example: 2

     *               description:

     *                 type: string

     *                 format: binary

     *                 description: File upload for resource_type 2 or 3

     *               category_id:

     *                 type: integer

     *                 example: 1

  • scot1967's avatar
    scot1967
    Icon for Champion Level 3 rankChampion Level 3

    Hello pb9034,

    I see 'postman' mentioned here so I gather you are using this to test an API and need to know how to make the call correctly.  If the image you posted is the API front end, it looks like you would pass the image or audio file in as a 'blob' in a string.  Much like files are attached to emails using a Base 64 encoded string.  The resource type field would be used by the API to determine what you are sending, a text string or a binary.

    Please be kind, I may be way off here.  I am not an API dev but I have done some API testing with SOAP UI and Ready API.  (I edited out my ref to Swagger, that is all we use where I work.)

    ... If you find my posts helpful drop me a like! 👍 Be sure to mark the best answer if you get one to help others out and to credit the one who helped you.  😎