I’m trying to connect my app to WhisperAPI.com 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.
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
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?
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:
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
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?
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}