16
Views
2
Comments
Need to Pass Binary Data of Audio to consumed post Open AI API
Question

Hello,

I'm consuming Open AI API (post https://api.openai.com/v1/audio/transcriptions), added the authentication of Bearer token, working as expected.

The method SS

It requires two parameters

1. file

2. model

file SS

model SS


In response I'm getting the below error.

{

  "error": {

    "message": "[{'type': 'value_error', 'loc': ('body', 'file'), 'msg': \"Value error, Expected UploadFile, received: \", 'input': 'ID3\\x04\\x00\\x00\\x00\\x00\\x01............

For me it seems it sending string and expected was file.

I'm passing the binary data from Resource content.

Any help on this?

API Working as expected in Postman.


2023-01-19 12-23-07
Abhinav Shilwant

Hi @Rituraj Chouhan,

It seems the API expects a file upload (like UploadFile), but you’re passing the binary content directly, which might be causing the issue.

In OutSystems, ensure you’re using the correct MultipartFormData content type for the file upload. Instead of passing binary data, use the file input parameter in your API call to properly send the file as multipart data.

If it works in Postman, check how the file is being passed there and replicate that structure in OutSystems.

Let me know if this helps!

2023-01-19 12-23-07
Abhinav Shilwant

+ Addition to the above,

To fix this in OutSystems, follow these steps:

1) Set the Content-Type to multipart/form-data in your API request.

2) For the “file” parameter, use BinaryDataToUpload instead of just binary data. This will properly format the file for the request.

3) Make sure you’re passing the file with the correct filename and MIME type.

Here’s a quick example:

  • Use CreateUpload to pass the file as UploadFile in the body.
  • Ensure that the model parameter is passed as plain text.

This should resolve the issue.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.