Uploading a Doctype using POSTMAN desktop lose file in the attach field

Hi all,
I’m facing a problem testing a post API with POSTMAN to upload a custom doctype.

My set is like that:

I have a custom doctype named “Record”, this doctype has some different field and among them i’ve created an attach field named “file”.

Creating a new Record from the User Interface goes well attaching the file using the attach button.

I want to create a new record with an attached file using the post API endpoint.

I’m testing it using POSTMAN desktop in a linux enviroment.

The creation of the record without the file attached goes well without any problem, but if i try to attach the file in the post request, when the new record is created is created without the attached file, leaving the file attach field as None.

This is my request in Postman (I setted everthing as it should be i think: i’m uploading the file in postman selecting the file type in the request and selecting the file from my pc )

And this is the response from frappe:
image

I’m really lost in that what should i do?

You may need to create a File record. Then “Record” record, then you need to attach the file in to the Record.

Additional Info:REST API

1 Like

I know that i can upload a file using the dedicated method /api/method/upload_file that accepts binary file data and uploads it into the system.

But i would like to avoid this workaround and make the API to upload a new Record to accept binary files in the form-data.

In example i was thinking to modify this code that manage POSTs (/frappe/frappe/api.py) requests to if it intercepts a binary file in the form of a POST request for a Record Doctype it will in some way manage the file and attach it in the record field. But now i don’t know how to do that.
image