How to upload file from Salesforce to Assistants API for File Search?

As we are integrating Salesforce to Open AI Assistants - Upload File API, we discovered that the API doesn’t accept blob/base 64 encoding format of files. It accepts only the actual file in the API request body using “form-data” method.

Unfortunately, we are not able to find a way to send the file in form-data method via Apex to the REST API. When we surfed through Salesforce forums as well, we are finding answers from the community that Apex is not supporting this kind of API calls currently.

Has anyone integrated Salesforce to Assistant API for File Search use case before? It would be great if we can get some guidance on this.

2 Likes

I have the exact same issue. I’m trying to implement a solution where we can directly upload files from Salesforce to OpenAI, but as far as I can tell, this method of uploading files is not supported on the Salesforce side. If anyone finds a solution other than a middleware, it would be much appreciated!