Trouble Using WhisperAPI

I’m trying to connect my app to which hosts a version of OpenAI’s whisper for voice to test transcription. I’ve got voice recording working and I can pull a url for the MP4 from Cloudinary but I get nothing from the web API.

Here’s what the documentation says:

Here’s what I’m currently doing:

I’m sure I’m getting the JSON part wrong but I’m not sure where to start error checking here.

I’m pretty sure your object needs to be part of the Body, not the Query Parameters. And you’ll need to convert it to JSON like this example from one of my projects:

Also, as you test an API, it’s best to do error handling. Inside of the Post call’s “then do” section, set it up with an If block: If [error] then set label’s text to [error]; else set label’s text to [response].

Lastly, the “fileType” property may be case-sensitive so I would fix that. This info from Microsoft states that at least for their specific API, body properties are case-sensitive.

Report back the error value you’re seeing and/or the response value you’re seeing. While testing, it can be useful to replace the label with a text input component because then you can copy & paste the displayed text rather than having to screenshot it.

OK - back from holiday (sorry for the slow response).
I’ve tweaked the sections you mentioned (still need to get used to capitalisation conventions). I stripped out some of the error checking to try and simplify it when I was troubleshooting as I had seen one instance of an error check causing an issue. Anyway, here’s what I’m working with now. The error I get back say there’s no url or file sent (it wants one or the other, but not both). I can clearly see the url flash up before the error though so I don’t know why it’s not happy

The actual error - in case formatting infers syntax is: {“error”:“Neither URL was set nor file was sent!”}
If I run in a browser it gives me: “Failed to fetch data. Please test on a device or contact support.”

It still does this even if I hardcode the url into the JSON block instead of using an app variable or green ‘url’ block

What happens if you remove the “file” property from the object?

Yeh, great minds. I just tried that too and it made no difference.
I also tried changing the Query Params into Body and it gives me a “Network Request Failed”

So, I’m guessing Query Parameters is correct. It just doesn’t think I’ve added a url in. I wonder if it’s not correctly formatted. Or, if Thunkable is changing the format given the type of variable I’m using?

If I just do this:

It says my variable is just [object Oject] which i guess means my JSON contains nothing :confused:

Did you test it using the Thunkable live app?
Maybe this error is on the web app

Yeh it doesn’t work at all in the Web App. I’m now running it on my OnePlus 8 Pro (android 13)

OK - so if I try to output the contents of the variable without doing a ‘get object from JSON’ I get the contents. But I’m not 100% sure it’s formatted correctly:


^^ Is this the correct format?

Needs to match this:

I replaced the smart quotes* in that JSON response and pasted it into to see the JSON structure.

That allows me to see that you can get the url by getting the property “data.url” of that object.

*To avoid having to do this, always use this forums toolbar button to format the text:

OK the cause doesn’t surprise me. When I posted the JSON in above I did wonder why it had highlighted as it had.

I’m a bit fuzzy on whether the JSON I’m building in the app is correct though and whether there’s anything I can do to make this right.

And - in case it’s relevant, the error I’m getting is coming from the API’s response, not the actual error. Status is reading 200. I’m wondering if it actually doesn’t accept MP4’s. list of acceptable files isn’t in the documentation :confused:

Nope - no dice there either. Converted to mp3 and re-tested. Hardcoded the url too and still no dice. Checked the output of the JSON again and it looks OK. I’ve pinged the API devs to see what they say too.

Sorry, it’s actually hard to help you troubleshoot when you’ve taken a couple different approaches. Looking over your last screenshots, I realize that all you did is to display the JSON for the object you created. You didn’t actually do a Post call to the API and get a response.

That’s why the JSON contains an .mp4 of your voice saying “testing, testing, transcribe.”

Can you post a screenshot of the current blocks you’re using to call the API?

Sorry for the confusion - I’ve been back and forth trying to troubleshoot everything I could think of for hours now. Here’s what I’m currently running:

I’m thinking it’s got to be the format of the JSON I’m actually uploading, not being what the API wants to see. Something to do with the file ={} and data = {} sections perhaps?

Can you try switching from QueryParameters to Body again and test it on a phone? What error do you get, if any?

And with it set again to QueryParameters, what error are you seeing on a phone?

So, I’m always testing it on a phone now as it doesn’t work at all on a web app.

With it set to Body it give a Network Request Failed
With it set to QueryParams again it says {“error”:“Neither URL was set nor file was sent!”}

Also, got a reply from the devs saying:
I think your issue may be that you need to include all the -F parameters in the header. Here is a thunkable post that explains a bit:

This seems to suggest they’re using curl to do the API request, which I’m not. I tried adding all the parameters to the header instead and then it doesn’t have authorisation. I then tried adding the API key into the API POST call JSON as a separate JSON parameter but that didn’t work either {sigh}